最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论