When we want to move to another Activity
using Intent
in Kotlin
, it gives this error.
In Intent
, it doesn’t recognize .java
after ::class
look:
And when I delete .java
, Intent
gives an error
Note: My problem was not solved with Invalidate Caches / Restart...
option in File
I don’t know where the problem is. please help me.
2
Answers
The solution is:
In
build.gradle (:app)
file, independencies
, you should changeappcompat
version to1.4.2
.befor error:
And when I changed the version to
1.4.2
, the problem was solvedAnd make sure the
kotlin
version is1.5.0
Kinda strange because it seems good to me. Try this.
Remove the lateinit and declare it directly when you need it, maybe it will solve the problem.
I don’t think the
this@KotlinActivity
is needed in this case.Let me know if this fix it
UPDATE
Are you sure the
findViewById<TextView>...
is correct ? Shouldn’t it has a declaration before ? Like