1

I had this issue when I try to setup my project on my new pc. enter image description here

FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':in_app_update:compileDebugKotlin'. A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction

I tried to find the solution here and some says its because of the kotlin version enter image description here

I need some pointers out here, thanks in advance!

4
  • Have you looked at the solutions in this link? stackoverflow.com/questions/59893018/… Commented Jan 24, 2023 at 5:55
  • I tried the steps where I have to upgrade the kotlin version Commented Jan 24, 2023 at 6:05
  • This problem can sometimes be related to gradlew. I recommend that you check it out. Commented Jan 24, 2023 at 6:20
  • I checked it out, and still same problem, i upgraded the kotlin version too Commented Jan 24, 2023 at 6:21

1 Answer 1

2

Without more context is hard to say, but when compilation fails the errors are usually listed somewhere else (before the failure). Read the whole output of Gradle and look for lines starting with e:.


Looking at your first image which says:

> Task :app:kaptGenerateStubsDebugKotlin 'compileDebugJavaWithJavac' task (current target is 1.7) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.

Depending on your Kotlin version and gradle.properties contents the JVM incompatibility might be a warning or an error. Since it doesn't say "it will become an error", suggests that the flag is on error.

This is the part I'm missing:

By default will become an error since Gradle 8.0+! Read more: https://kotl.in/gradle/jvm/target-validation
Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

So you have a few options. Set up your PATH / JAVA_HOME to point to Java 7 installation, I think you have Java 8 now, but the project expects 7 (or the other way around). Without seeing targetCompatibility / jvmTarget DSL, it's hard to tell.

Anyway, just recently we reported a similar issue to Kotlin and they provided a very clean solution: https://youtrack.jetbrains.com/issue/KTIJ-24311/#focus=Comments-27-6798448.0-0

build.gradle (for each module):

kotlin {
    jvmToolchain(7)
}

This is what the documentation also suggests.


If you can't make it work by juggling Java versions, you can disable the warning and maybe that will make it work:

gradle.properties:

kotlin.jvm.target.validation.mode=ignore

This is documented here. Please understand what you're turning off and that it'll break things now or in the future if you do.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.