Open tomcatvr opened 9 months ago
After further research it turns out that the error appears useing kotlin >=1.8.0 but as my app uses com.google.gms.google-services which is compiled with a newer version of kotlin, it ends up with: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1
So, could you please update the plugin with a new version of kotlin in the build.gradle file with at least ext.kotlin_version = '1.7.10'? Thanks Carlo
Encountering the same issue in my project. Seems like this PR should solve this, but there has been no action since October 😬
@tomcatvr check out this comment, seems to be working as a workaround for me at the moment!
@tomcatvr check out this comment, seems to be working as a workaround for me at the moment!
@adigladi Thanks very much, it worked!
This looks totally different than what I use (https://github.com/flutter/flutter/issues/125181#issuecomment-1555034383) I use version 34 and 1.8
This is the error I get
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':video_compress:compileDebugKotlin'.
Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'compileDebugKotlin' (17).
Consider using JVM Toolchain: https://kotl.in/gradle/jvm/toolchain Learn more about JVM-target validation: https://kotl.in/gradle/jvm/target-validation
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org.
BUILD FAILED in 5m 12s Error: Gradle task assembleDebug failed with exit code 1
settings.gradle
pluginManagement { def flutterSdkPath = { def properties = new Properties() file("local.properties").withInputStream { properties.load(it) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath } settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
plugins {
id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
}
}
plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.1" apply false }
include ":app"
android\build.gradle
buildscript { //https://kotlinlang.org/docs/releases.html#ide-support // ext.kotlin_version = '1.7.10' // ext.kotlin_version = '1.9.21' ext.kotlin_version = '1.9.22'
repositories {
google()
mavenCentral()
}
dependencies {
// 7_2_0
// classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.android.tools.build:gradle:8.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// classpath 'com.google.gms:google-services:4.3.15' classpath 'com.google.gms:google-services:4.4.1' // classpath 'com.google.gms:google-services:4.3.15'
// Add the Crashlytics Gradle plugin
//2_9_2
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
// Add the dependency for the Performance Monitoring Gradle plugin
classpath 'com.google.firebase:perf-plugin:1.4.2'
}
}
allprojects { repositories { google() mavenCentral() } }
rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') }
tasks.register("clean", Delete) { delete rootProject.buildDir }
app\build.gradle
plugins { id "com.android.application" id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" }
def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } }
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' }
def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' }
//apply plugin: 'com.android.application'
//apply plugin: 'kotlin-android'
//apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
// Apply the Firebase Crashlytics Gradle plugin
apply plugin: 'com.google.firebase.crashlytics'
//Apply the Firebase Performance Gradle plugin
apply plugin: 'com.google.firebase.firebase-perf'
android { namespace "com.app.app" compileSdkVersion 34 // compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.app.app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
// minSdkVersion flutter.minSdkVersion // targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName minSdkVersion 24 targetSdkVersion 34 multiDexEnabled true }
signingConfigs {
release {
// storeFile file('H:\FlutterPlaystore\app\key.jks') storeFile file('H:/FlutterPlaystore/app/key.jks') storePassword 'password' keyAlias 'alias' keyPassword 'password' } }
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
// signingConfig signingConfigs.release
}
}
}
flutter { source '../..' }
dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// implementation 'com.android.support:multidex:1.0.3' implementation "androidx.multidex:multidex:2.0.1"
// Import the BoM for the Firebase platform
// implementation platform('com.google.firebase:firebase-bom:31.1.1') implementation(platform("com.google.firebase:firebase-bom:32.7.0")) // implementation(platform("com.google.firebase:firebase-bom:33.1.0")) // Add the dependency for the Performance Monitoring library // When using the BoM, you don't specify versions in Firebase library dependencies implementation 'com.google.firebase:firebase-perf' // Declare the dependencies for the Crashlytics and Analytics libraries // When using the BoM, you don't specify versions in Firebase library dependencies implementation 'com.google.firebase:firebase-crashlytics' implementation 'com.google.firebase:firebase-analytics'
}
gradle-wrapper.properties
I followed instructions from record pubdev which also causes similar problems
https://github.com/llfbandit/record/issues/333
But after solving record pubdev problem the problem for video_compress appeared, I don't understand what I should change in these classes I posted according to the advice provided above by @tomcatvr
This looks totally different than what I use (flutter/flutter#125181 (comment)) I use version 34 and 1.8
This is the error I get
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':video_compress:compileDebugKotlin'.
Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'compileDebugKotlin' (17).
Consider using JVM Toolchain: https://kotl.in/gradle/jvm/toolchain Learn more about JVM-target validation: https://kotl.in/gradle/jvm/target-validation
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org.
BUILD FAILED in 5m 12s Error: Gradle task assembleDebug failed with exit code 1
settings.gradle
pluginManagement { def flutterSdkPath = { def properties = new Properties() file("local.properties").withInputStream { properties.load(it) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath } settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") repositories { google() mavenCentral() gradlePluginPortal() } plugins { id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false }
}
plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.1" apply false }
include ":app"
android\build.gradle
buildscript { //https://kotlinlang.org/docs/releases.html#ide-support // ext.kotlin_version = '1.7.10' // ext.kotlin_version = '1.9.21' ext.kotlin_version = '1.9.22'
repositories { google() mavenCentral() } dependencies {
// 7_2_0 // classpath 'com.android.tools.build:gradle:7.3.1' classpath 'com.android.tools.build:gradle:8.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// classpath 'com.google.gms:google-services:4.3.15' classpath 'com.google.gms:google-services:4.4.1' // classpath 'com.google.gms:google-services:4.3.15'
// Add the Crashlytics Gradle plugin //2_9_2 classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9' // Add the dependency for the Performance Monitoring Gradle plugin classpath 'com.google.firebase:perf-plugin:1.4.2' }
}
allprojects { repositories { google() mavenCentral() } }
rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') }
tasks.register("clean", Delete) { delete rootProject.buildDir }
app\build.gradle
plugins { id "com.android.application" id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" }
def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } }
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' }
def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' }
//apply plugin: 'com.android.application' //apply plugin: 'kotlin-android' //apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply plugin: 'com.google.gms.google-services' // Apply the Firebase Crashlytics Gradle plugin apply plugin: 'com.google.firebase.crashlytics' //Apply the Firebase Performance Gradle plugin apply plugin: 'com.google.firebase.firebase-perf'
android { namespace "com.app.app" compileSdkVersion 34 // compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.app.app" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
// minSdkVersion flutter.minSdkVersion // targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName minSdkVersion 24 targetSdkVersion 34 multiDexEnabled true }
signingConfigs { release {
// storeFile file('H:\FlutterPlaystore\app\key.jks') storeFile file('H:/FlutterPlaystore/app/key.jks') storePassword 'password' keyAlias 'alias' keyPassword 'password' } }
buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug
// signingConfig signingConfigs.release
} }
}
flutter { source '../..' }
dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// implementation 'com.android.support:multidex:1.0.3' implementation "androidx.multidex:multidex:2.0.1"
// Import the BoM for the Firebase platform
// implementation platform('com.google.firebase:firebase-bom:31.1.1') implementation(platform("com.google.firebase:firebase-bom:32.7.0")) // implementation(platform("com.google.firebase:firebase-bom:33.1.0")) // Add the dependency for the Performance Monitoring library // When using the BoM, you don't specify versions in Firebase library dependencies implementation 'com.google.firebase:firebase-perf' // Declare the dependencies for the Crashlytics and Analytics libraries // When using the BoM, you don't specify versions in Firebase library dependencies implementation 'com.google.firebase:firebase-crashlytics' implementation 'com.google.firebase:firebase-analytics'
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https://services.gradle.org/distributions/gradle-8.6-all.zip
I followed instructions from record pubdev which also causes similar problems
But after solving record pubdev problem the problem for video_compress appeared, I don't understand what I should change in these classes I posted according to the advice provided above by @tomcatvr
@Megatronicus have you found any solution to your problem? I am encountering the same issue and I have been stuck on this for a week, I need help.
try upgrade org.jetbrains.kotlin.android
to latest version:
- id "org.jetbrains.kotlin.android" version "1.7.10" apply false
+ id "org.jetbrains.kotlin.android" version "1.9.24" apply false
This is what fixed it for me. I recognise that this is probably a hack, covering up the real issue, but maybe it'll get you out of Java Jail:
Top level build.gradle
file:
allprojects {
repositories {
google()
mavenCentral()
}
// Added this block:
afterEvaluate { project ->
if (project.hasProperty("kotlin")) {
project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
}
}
this works for me compileOptions { // sourceCompatibility JavaVersion.VERSION_17 // targetCompatibility JavaVersion.VERSION_17 coreLibraryDesugaringEnabled true
}
kotlin {
jvmToolchain(17)
}
Hi, Where did you placed kotlin, inside android or outside?
this works for me compileOptions { // sourceCompatibility JavaVersion.VERSION_17 // targetCompatibility JavaVersion.VERSION_17 coreLibraryDesugaringEnabled true
} kotlin { jvmToolchain(17) }
here, is the full code. `plugins { id "com.android.application" // START: FlutterFire Configuration id 'com.google.gms.google-services' // END: FlutterFire Configuration id "kotlin-android" // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id "dev.flutter.flutter-gradle-plugin" }
android {
compileSdkVersion = 34
ndkVersion = '27.0.12077973'
compileOptions {
coreLibraryDesugaringEnabled true
}
kotlin {
jvmToolchain(17)
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = ""
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdkVersion 23
targetSdkVersion 34
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.debug
}
}
}
flutter { source = "../.." }
dependencies {
implementation platform("com.google.firebase:firebase-bom:33.1.0")
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
}
`
Hi, after upgrading to the latest flutter plugin I get this error on compiling the module Here is my build.gradle config ... android { compileSdkVersion 34 ndkVersion flutter.ndkVersion
...
The complete error is Execution failed for task ':video_compress:compileDebugKotlin'.
Dart plugin: 231.9411 Flutter plugin: 77.2.1 Flutter version 3.13.9 Dart version 3.1.5
Thanks Carlo