I am migrating a Java android app to Kotlin class for class with Android Studio's Convert Java file to Kotlin file
.
My android project consists of three modules/projects where the top project has no code of its own:
overall
├─ app
└─ model
I've converted a file in model
to Kotlin and it is recognized by the Java classes in model
.
But for classes in app
there are problems. While the class itself is accepted as e.g. a method parameter, method references are not possible. E.g. for foo.ba()
android studio will show a box with the Javadoc but the term in the source file is red underlined and the error is Cannot access kotlin.jvm.internal.markers.KMappedMarker
.
To see if the problem is due to Android Studio, I ran gradle --warning-mode all sudoqapp:assembleRelease
in the terminal which fails with error: cannot access KMappedMarker
and class file for kotlin.jvm.internal.markers.KMappedMarker not found
. So I assume the error is in the build.gradle files which were automatically converted.
overall
has
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.5.0-RC'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
app
has no kotlin references at all and
model
has
apply plugin: 'kotlin'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
buildscript {
ext.kotlin_version = '1.5.0-RC'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}