I’m trying to upgrade my Android Gradle Plugin to 8.0 with the latest stable Flamingo release.
However, I get this issue after running the AGP upgrade assistant and trying to run the build.
Caused by: org.gradle.api.GradleException: 'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
I’ve updated these lines in the build.gradle files
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
However, I’m still getting this issue.
What does this issue mean and how can I fix it?
4
Answers
it seems that the ‘compileDebugJavaWithJavac’ task is set to target Java version 1.8, while the ‘compileDebugKotlin’ task is set to target Java version 17. This mismatch can cause issues during the build process.
you’ll need to ensure that the Java version target compatibility for both tasks is set to the same value.u can try updateing the
build.gradle
file as follows:These might help you
This code snippet syntax is deprecated :
use this instead :
Try to do it.
with this setup you can use AGP version 8.0.0.
and also set the Gradle JDK to Embedded KDL in your android studio settings.
finally, clean your build and rebuild again