Inconsistent JVM-target compatibility: compileReleaseJavaWithJavac (1.8) and compileReleaseKotlin (17) in Flutter Android Build

Execution failed for task ':photo_manager:compileReleaseKotlin'.Inconsistent JVM-target compa

Execution failed for task ':photo_manager:compileReleaseKotlin'.

Inconsistent JVM-target compatibility detected for tasks 'compileReleaseJavaWithJavac' (1.8) and 'compileReleaseKotlin' (17).

My setup:

  • Flutter version: 3.22.4
  • Gradle version: 8.11.1
  • Android Gradle Plugin (AGP): 8.9.0
  • Kotlin version: 2.1.10
  • JVM version: 17
  • compileSdk: 35

What I’ve tried:

  1. Ensuring Java Compatibility: In android/build.gradle and android/app/build.gradle:
android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
}
  1. Setting Kotlin JVM Target: In android/gradle.properties:
kotlinpiler.jvmTarget=17
  1. Adding Java Toolchain to Gradle: In android/app/build.gradle:
java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(17))
    }
}
  1. Adding Kotlin Toolchain to Gradle:
kotlin {
  jvmToolchain(17)
}

Even after these changes, the error still persists. I also tried downgrading the Kotlin target to 1.8 to match Java, but it didn’t help.

How can I resolve this JVM-target inconsistency?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744606563a4583503.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信