skip to Main Content

enter image description here

Task :app:compileDebugKotlin FAILED

Type mismatch: inferred type is String but Int was expected

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search