ksp: kspDebugKotlin task fails because of JVM target mismatch on latest 1.0.9 version
Hi! I just upgraded my project to Kotlin 1.8.0 and ksp v1.8.0-1.0.9, and now I’m getting this error when building the app:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kspDebugKotlin'. <30 lines>
Caused by: org.gradle.api.GradleException: 'compileDebugJavaWithJavac' task (current target is 11) and 'kspDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.validateKotlinAndJavaHasSameTargetCompatibility(Tasks.kt:797)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin_common(Tasks.kt:722)
at com.google.devtools.ksp.gradle.KspTaskJvm.callCompilerAsync$kotlin_gradle_plugin_common(KotlinFactories.kt:189)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin_common(Tasks.kt:530)
at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.executeImpl(Tasks.kt:450)
<... many more lines>
I never set the JVM to 17 anywhere in the project (with the only exception being that the JDK on which the IDE/Gradle runs is using JDK 17), so this is a pretty weird error to face.
Hope you could assist me with this bug.
Android Studio version: 2022.3.1 Canary 2 (Giraffe). Android Gradle Plugin version: 8.1.0-alpha02 Gradle version (in wrapper): 8.0-rc-1 Kotlin version: 1.8.0 JVM target (in build.gradle.kts): Java 11 Library using ksp: Room Persistence Library
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 22
- Comments: 26 (4 by maintainers)
Commits related to this issue
- Deps: Update compose compiler to 1.4.0 version This update also: - Updates kotlin to 1.8.0 version. - Updates ksp to 1.8.0-1.0.8 version. ------------------------------------------------------------... — committed to ParaskP7/sample-code-movies by ParaskP7 a year ago
- Deps: Update compose compiler to 1.4.7 version This update also: - Updates kotlin to 1.8.21 version. - Updates ksp to 1.8.21-1.0.11 version. ---------------------------------------------------------... — committed to ParaskP7/sample-code-movies by ParaskP7 a year ago
- feat: https://github.com/google/ksp/issues/1288 の問題のためkotlinとkspをダウングレード kotlin: 1.8.10 -> 1.8.0, ksp: 1.8.10-1.0.9 -> 1.8.0-1.0.8 — committed to mofutaro/BGCountdownTimer by mofutaro a year ago
- Temporary fix for KSP-related warning (revert for 1.9) KSP doesn't propagate Kotlin version correctly, applied workaround to make the build pass. Github issue: https://github.com/google/ksp/issues/1... — committed to androidx/androidx by ShikaSD a year ago
- :adhesive_bandage: :label: update gradle :app :core - need-fixed when gradle update and using `kapt` - issue https://github.com/google/ksp/issues/1288 — committed to im-o/android-compose-haidoc-ui by im-o 8 months ago
This worked for me after updating the AGP to 8.0.1
Yes the fix will be shipped with next release.
I just noticed that this issue is specific to KSP version 1.8.0-1.0.9, whereas reverting back to 1.8.0-1.0.8 works just fine.
Hi I’m getting the same error : ‘compileDebugJavaWithJavac’ task (current target is 17) and ‘kspDebugKotlin’ task (current target is 1.8) jvm target compatibility should be set to the same Java version. Can you tell me the Java Version that you used @Nyae44
I noticed same behavior with ksp version
1.8.10-1.0.9
here is the stacktrace:
above additional configuration seems to fixed the issue for me.
The fix is shipped with 1.9.0-1.0.12, consider upgrade to this version to see if issue resolves.
Same thing for me with a default generated KMM project using the latest canary Android Studio.
Upgraded the compileSdk to 34 and also changed the sourceCompatibility and targetCompatibility to be of the same java version as the jvmTarget. It worked!
I am experiencing the same problem. @neetopia Here is the demo repository and here is the link for the failing build workflow.