Home > OS >  compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expect
compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expect

Time:01-31

I am rebuilding my android project which is in java and some classes are written in kotlin. I have search on google but my problem didn't solve. I am getting below error while building my project:

/home/bansal/.gradle/caches/transforms-2/files-2.1/0bea321a20a76ca878f594ef198fedcf/jetified-core-ktx-1.10.0-alpha02-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.

Below is my build.gradel

ext.kotlin_version = '1.6.10'
repositories {
    google()
    jcenter()
    maven {
        url 'http://dl.bintray.com/amulyakhare/maven'
    }
}
dependencies {
    classpath "com.android.tools.build:gradle:4.0.1"
    classpath 'io.realm:realm-gradle-plugin:3.2.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

and module build.gradle

  compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

dependencies{
    implementation 'androidx.core:core-ktx:1.7.0'


    annotationProcessor 'android.arch.lifecycle:compiler:1.1.1'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'android.arch.lifecycle:viewmodel:1.1.1'
    implementation 'android.arch.lifecycle:extensions:1.1.1'

    //Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1'
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
    implementation "androidx.core:core-ktx: "
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

Tried solutiuon: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15

CodePudding user response:

This same issue i got before a few days .. and solution is too easy for this

In your build.gradle file (which you pasted first) , same classpath is written twice so remove any once of them

From

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" // you can remove this
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

In your module level build.gradle file , same dependency is mentioned twice

From

implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.core:core-ktx: " // you can remove this

sync gradle and try to run to your project

CodePudding user response:

I had a similar problem and found a dissimilar solution. Android Studio suggested I update to Electric Eel from Dolphin. Figuring things couldn't get worse, I did it, and ta da - the problem went away!

  • Related