I am trying to update my android project to gradle 8.0. Which also requires an update to jdk 17.
Here is what I think the relevant parts in my build file:
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
kotlinOptions {
jvmTarget = "17"
}
gradle wrapper:
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Top level gradle file:
plugins {
id 'com.android.application' version '8.0.0' apply false
id 'com.android.library' version '8.0.0' apply false
...
}
When I build I am getting the following error:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
> java.lang.reflect.InvocationTargetException (no error message)
Viewing other posts I have found its a possible bug with a workaround:
tasks.withType<KaptGenerateStubsTask>().configureEach {
kotlinOptions.jvmTarget = libs.versions.java.bytecode.version.get()
}
However according to this answer: How to configure kapt to generate Java17 Java stubs in Android Gradle build file
You can just use:
kotlin {
jvmToolchain(17)
}
Anyone using gradle 8.0 and jdk 17 successfully? If so any ideas?