Jorge Domínguez

02/09/2023, 2:15 AM
after updating my project to Kotlin 1.8.0 I'm getting the following build error:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 1.8) and 'kaptGenerateStubsDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
  Consider using JVM toolchain: <>
but my Gradle config is:
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
kotlinOptions {
    jvmTarget = "1.8"
so I'm not sure where target 17 is setup, has somebody experienced the same error?
fixed it by doing
allprojects {
    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
        kotlinOptions {
            jvmTarget = JavaVersion.VERSION_1_8.toString()
which I guess forces the JVM target version of every Kotlin task, but still don't know what was happening before 🤔

Daniele Segato

02/25/2023, 10:57 AM
I'm having the same issue, is this workaround really needed? Can anyone explain why I get this error?
These 2 issues talk about this: And apparently the issue was caused by Jetbrain: It seems the solution is to set
kotlin {
Also updating your target from 1.8 to 11 as far as I understood. in all the projects (or 17 depending on what you use). I posted another question here because I'm also a bit confused by the changes:

Bruno Braga

03/12/2023, 1:54 AM
The snippet below has worked for me:
constraints {
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
        because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
        because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
inside of the dependencies{ } gradle :app.