skip to Main Content

After creating a screen to display the user’s location on the map, I get the following errors:

e: /path/to/project/.gradle/caches/transforms-3/XXXXXX/transformed/fragment-1.7.1-api.jar!/META-INF/fragment_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

e: /path/to/project/.gradle/caches/transforms-3/XXXXXX/transformed/jetified-activity-1.8.1-api.jar!/META-INF/activity_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

e: /path/to/project/.gradle/caches/transforms-3/XXXXXX/transformed/jetified-lifecycle-livedata-core-ktx-2.7.0-api.jar!/META-INF/lifecycle-livedata-core-ktx_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

e: /path/to/project/.gradle/caches/transforms-3/XXXXXX/transformed/lifecycle-livedata-2.7.0-api.jar!/META-INF/lifecycle-livedata_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

e: /path/to/project/.gradle/caches/transforms-3/XXXXXX/transformed/lifecycle-viewmodel-2.7.0-api.jar!/META-INF/lifecycle-viewmodel_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

e: /path/to/project/.gradle/caches/transforms-3/XXXXXX/transformed/core-ktx-1.13.1-api.jar!/META-INF/core-ktx_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

Android/build.gradle

buildscript {
    ext.kotlin_version = '1.9.0'
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:8.0.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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
}

Android/app/build.gradle:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

android {
    namespace = "com.example.projectexample"
    compileSdk = 34

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    defaultConfig {
        applicationId = "com.example.projectexample"
        minSdk = 21
        targetSdk = 34
        versionCode = 1
        versionName = "1.0.0"
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            signingConfig signingConfigs.debug
        }

        debug {
            minifyEnabled false
            shrinkResources false
        }
    }
}

flutter {
    source = "../.."
}

dependencies {
    implementation "androidx.core:core-ktx:1.13.0"
    implementation "androidx.fragment:fragment-ktx:1.7.1"
    implementation "androidx.lifecycle:lifecycle-livedata-core-ktx:2.7.0"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1"
}

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.1.1-all.zip

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

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.3.0" apply false
    id "org.jetbrains.kotlin.android" version "1.9.0" apply false
}

include ":app"

2

Answers


  1. First, i guess it’s a warning not an error?

    So the error show that you have a different kotlin version with the expected one. Based on you gradle, your gradle version is 8.1.1 and your kotlin version is 1.9.0. Based on Gradle Compability Matrix, Kotlin 1.9.0 is supported by Gradle version 8.3.

    You should check that compability matrix to synchronize the version between Gradle, Kotlin, and Android Gradle Plugin (AGP).

    So what you can do here is (2 option):

    1. Upgrade your Gradle

    • Find android/gradle-wrapper.properties file
    • Change the distributionUrl to
    distributionUrl=https://services.gradle.org/distributions/gradle-8.3-all.zip
    
    • Then save it.

    To upgrade your gradle you need to check the Java version that compatible with your installed gradle

    2. Downgrade Kotlin Version

    If you already did the option 1 then no need to do the option 2.

    • Find android/settings.gradle
    • Change your kotlin version in plugins section to
    id "org.jetbrains.kotlin.android" version "1.8.10" apply false
    

    Your previous kotlin version is 1.9.0 then i changed it to 1.8.10 for compability with your Gradle version (8.1.1)

    Login or Signup to reply.
  2. The issue is your Kotlin Version is not compatible with your Gradle Version.
    All you need just change the Kotlin and Gradle version. According to this table.

    You have to apply one by one, which version that is compatible with your project you can choose, because there might be some issue if you upgrade or downgrade the gradle versions, because some dependencies will be affected. So, you have to try Different gradle versions and their corresponding Compatible kotlin version.

    Your Issue will be resolved
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search