As the title says, I've installed new Android Studio but can't compile my project anymore. After failing in kapt
I have migrated everything to ksp
but still no luck. I do have following configurations from day 1:
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
After looking everywhere and trying multiple solutions - nothing works.
After digging for a solution I found this one working for me. Might be useful for you too.
I. For kapt:
build.gradle.kts
android{
//...
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
kotlin {
jvmToolchain(17)
}
//...
}
I'm guessing that's because both JDKs are under the same folder AS and gradle needs to know what version of compiler/toolchain to pick. Apparently compileOptions
and kotlinOptions
aren't obvious enough.
II. For ksp
Update to id("com.google.devtools.ksp") version "2.0.0-1.0.22"
and kotlin id("org.jetbrains.kotlin.android") version "2.0.0"
. Should work without specifying jvmToolchain(17)
.
Also make sure that:
id("com.android.application") version "8.7.1"