after updating my project to Kotlin 1.8.0 I'm gett...
# android
j
after updating my project to Kotlin 1.8.0 I'm getting the following build error:
Copy code
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: <https://kotl.in/gradle/jvm/toolchain>
but my Gradle config is:
Copy code
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
Copy code
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 🤔
d
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: https://issuetracker.google.com/issues/265653154 https://issuetracker.google.com/issues/260059413 And apparently the issue was caused by Jetbrain: https://youtrack.jetbrains.com/issue/KT-55947/Unable-to-set-kapt-jvm-target-version#focus=Comments-27-6805028.0-0 It seems the solution is to set
Copy code
kotlin {
    jvmToolchain(11)
}
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: https://kotlinlang.slack.com/archives/C0B8M7BUY/p1677325937895979
b
The snippet below has worked for me:
Copy code
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.
8559 Views