Git Product home page Git Product logo

Comments (15)

dharmendrasinh-concetto avatar dharmendrasinh-concetto commented on August 17, 2024 5

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')
}

from flutter_contacts.

Valent1 avatar Valent1 commented on August 17, 2024 1

Yes, it fixes the issue and the app now compiles fine on Android. Thanks!

from flutter_contacts.

Valent1 avatar Valent1 commented on August 17, 2024

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'
    //}

from flutter_contacts.

beats0126 avatar beats0126 commented on August 17, 2024

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

from flutter_contacts.

beats0126 avatar beats0126 commented on August 17, 2024

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.

from flutter_contacts.

Valent1 avatar Valent1 commented on August 17, 2024

Nothing at all?

from flutter_contacts.

Valent1 avatar Valent1 commented on August 17, 2024

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")
}

from flutter_contacts.

joachim-quis avatar joachim-quis commented on August 17, 2024

Is this the same as #158 ?

from flutter_contacts.

Valent1 avatar Valent1 commented on August 17, 2024

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")
}

from flutter_contacts.

Valent1 avatar Valent1 commented on August 17, 2024

And yes, this is related to #147 and #158

And it still happens with version 1.1.8

from flutter_contacts.

arabnology avatar arabnology commented on August 17, 2024

OH cmon developer!!! we need real fix for this problem, can you please upgrade you package!!

from flutter_contacts.

arabnology avatar arabnology commented on August 17, 2024

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?

from flutter_contacts.

Valent1 avatar Valent1 commented on August 17, 2024

Can you please simply update the build.gradle file with the changes I have shown? It really takes 30 seconds, and fixes the issue.

from flutter_contacts.

arabnology avatar arabnology commented on August 17, 2024

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:
#142 (comment)

from flutter_contacts.

joachim-quis avatar joachim-quis commented on August 17, 2024

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.

from flutter_contacts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.