Skip to content Skip to sidebar Skip to footer

Go To Next Activity In Android Kotlin; Unresolved Class Reference

I am trying to go to next activity with my button listener and it says unresolved reference java Here is my code: btn?.setOnClickListener(object: View.OnClickListener { overr

Solution 1:

btn?.setOnClickListener {
   startActivity(Intent(this, NextActivity::class.java))
}

Solution 2:

Try to either upgrade Kotlin to the lastest version, or add a reference to kotlin-reflect below the stdlib dependency (will look like this):

compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

Solution 3:

As the @Hong Duan's comment

Possibly you have to add the kotlin's stdlib depency in your gradle script

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

Solution 4:

If you're using anko you can use the following

valintent= IntentFor<NextActivity>()

Post a Comment for "Go To Next Activity In Android Kotlin; Unresolved Class Reference"