anyone here was able to migrate to JDK 17 and keep...
# kapt
j
anyone here was able to migrate to JDK 17 and keep kapt working on android projects? Related link
t
I would advice you to configure Gradle JDK toolchain:
Copy code
kotlin.jvmToolchain(17)
j
The problem is that AGP 8.0 requires JDK 17, setting jvmToolChain 17, forces the bytecode to not be compatible with Android.
t
you mean running AGP 8.0 requires JDK 17?
j
Yes, but the bytecode should be compatible with Java 8/11
t
then use
kotlin.jvmToolchain(8)
while running Gradle build on JDK 17
j
With that the problem now is that, I will need to have JDK 17 and JDK 8/11 installed in the dev machine and CI server.
as stated in the stackoverflow thread.... Kotlin should not bind the bytecode compatibility with the jvmToolChain
t
Gradle should autoprovision missing JDKs required for build. If you really don't want to use toolchain - you could just configure Kotlin jvm target:
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
    compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8)
}
t
Yes, but the bytecode should be compatible with Java 8/11
That seems wrong to me. We have everything pointed at JDK17 and its been fine. D8/R8 seem to handle it fine. We also have library desugaring via
Copy code
# <https://developer.android.com/studio/write/java8-support#library-desugaring-versions>
desugar-jdk = { group = "com.android.tools", name = "desugar_jdk_libs", version = "2.0.3" }