I have an Android app written in Java and I am trying to write a new feature in Kotlin. So I added a new Kotlin file and IntelliJ offered to setup the project for Kotlin.
The issue is that when trying to create a Kotlin object in Java, compilation fails with
error: cannot find symbol constructor MyClassKt()
My Kotlin file (MyClass.kt):
val SCREEN = 1;
class MyClass() {
fun hello(view: View) {
}
}
In my app module:
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
In my project module:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Invocation in Java:
new MyClassKt();
apply plugin: 'kotlin-android'on the top of yourappmodule.