Closed Valent1 closed 1 month ago
I have also tried to comment out compileOptions and kotlinOptions in the app/build.gradle, replacing them with the jvmToolchain, but the error is still the same:
kotlin {
jvmToolchain(17)
}
//compileOptions {
// sourceCompatibility JavaVersion.VERSION_17
// targetCompatibility JavaVersion.VERSION_17
//}
//kotlinOptions {
// jvmTarget = '17'
//}
Having same issues.
Execution failed for task ':flutter_contacts:compileDebugKotlin'.
'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
Having same issues.
Execution failed for task ':flutter_contacts:compileDebugKotlin'.
'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
My setup
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.16.0, on Microsoft Windows [Version 10.0.22635.2771], locale en-US) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.5) [√] Android Studio (version 2022.3) [√] VS Code (version 1.84.2) [√] Connected device (4 available) [√] Network resources
dependencies {
classpath 'com.android.tools.build:gradle:8.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.4.0'
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
and multi flavor implemented.
Nothing at all?
I fixed this by adding:
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
to the build.gradle file. Please modify your build.gradle file as follows:
group 'co.quis.flutter_contacts'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.9.0'
ext.kotlin_coroutines_version = '1.6.4'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
rootProject.allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 31
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
if (!project.hasProperty("namespace")) {
namespace 'co.quis.flutter_contacts'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0")
}
Add below code in your project level build.gradle file. This worked for me. Also help me in other modules where same issue occurred.
rootProject.buildDir = '../build'
subprojects {
afterEvaluate {
if (project.plugins.hasPlugin("com.android.application")
|| project.plugins.hasPlugin("com.android.library")) {
if (project.name == "flutter_contacts") {
project.android.compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
}
}
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
Is this the same as https://github.com/QuisApp/flutter_contacts/issues/158 ?
I have already provided the solution, you simply need to implement it.
Add the following lines to your android/build.gradle:
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
Please refer to my previous message:
I fixed this by adding:
kotlin { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(8)) } }
to the build.gradle file. Please modify your build.gradle file as follows:
group 'co.quis.flutter_contacts' version '1.0-SNAPSHOT' buildscript { ext.kotlin_version = '1.9.0' ext.kotlin_coroutines_version = '1.6.4' repositories { google() jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:8.1.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } rootProject.allprojects { repositories { google() jcenter() mavenCentral() } } apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { compileSdkVersion 31 kotlin { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(8)) } } if (!project.hasProperty("namespace")) { namespace 'co.quis.flutter_contacts' } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { minSdkVersion 16 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } lintOptions { disable 'InvalidPackage' } } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version" implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0") }
And yes, this is related to https://github.com/QuisApp/flutter_contacts/issues/147 and https://github.com/QuisApp/flutter_contacts/issues/158
And it still happens with version 1.1.8
OH cmon developer!!! we need real fix for this problem, can you please upgrade you package!!
I have already provided the solution, you simply need to implement it.
Add the following lines to your android/build.gradle:
kotlin { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(8)) } }
Please refer to my previous message:
I fixed this by adding:
kotlin { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(8)) } }
to the build.gradle file. Please modify your build.gradle file as follows:
group 'co.quis.flutter_contacts' version '1.0-SNAPSHOT' buildscript { ext.kotlin_version = '1.9.0' ext.kotlin_coroutines_version = '1.6.4' repositories { google() jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:8.1.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } rootProject.allprojects { repositories { google() jcenter() mavenCentral() } } apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { compileSdkVersion 31 kotlin { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(8)) } } if (!project.hasProperty("namespace")) { namespace 'co.quis.flutter_contacts' } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { minSdkVersion 16 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } lintOptions { disable 'InvalidPackage' } } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version" implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0") }
Is there any negative effect on the project? I mean, is this affecting anything else in the project or breaking something?
Can you please simply update the build.gradle file with the changes I have shown? It really takes 30 seconds, and fixes the issue.
Can you please simply update the build.gradle file with the changes I have shown? It really takes 30 seconds, and fixes the issue.
This is what worked for me: https://github.com/QuisApp/flutter_contacts/issues/142#issuecomment-1898946388
Hi all - thanks for your patience and the recommended solutions.
This should be fixed in version 1.1.9. If it is not, please let me know, and reopen this conversation.
Yes, it fixes the issue and the app now compiles fine on Android. Thanks!
This issue started happening after upgrading my Kotlin version to 1.9.20 and Gradle plugin to 8.3.
Whenever I try to run the app on Android devices or Android emulator (no issues with iOS), I get this error message during assembleDebug:
I have tried to change the following in my app/build.gradle, but nothing seems to have any effect on the final result, I always get the same exact error:
This is the content of my android/build.gradle:
This is the content of my app/build.gradle:
This is the output of my flutter doctor -v: