Task :app:compileDebugKotlin FAILED
Type mismatch: inferred type is String but Int was expected
CodePudding user response:
What is the problem? The IDE itself tells you, an Int was expected but you are passing a String.
To get values from resources, for example, strings, themes, etc... you need to pass an Int or id of the resource, which is obtained by doing
R.id.your_resource
CodePudding user response:
So looking at your code:
val InterstitialId = dataSnapshot.child("interstitial_id").value.toString()
This line will return a string when you call the .toString
method, 2 lines below you are passing this variable to a .getString
and according to the documentation getString()
expects an Int not a String.