Home > Software engineering >  in_app_update:compileDebugKotlin error in Flutter build when debugging
in_app_update:compileDebugKotlin error in Flutter build when debugging

Time:01-25

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!

CodePudding user response:

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.

  • Related