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

Viewed 133724

In Stripe, my client wants email and cardholder name, but the Stripe payment UI doesn't provide that option in com.stripe.android.view.CardMultilineWidget. I wanted to give it a try with the latest stripe version,

  1. I was using Stripe version (14.1.1). So I updated it to the latest one (16.8.0)

  2. The build showed me the error that it doesn't take minSdkVersion 19. It requires 21 in manifest merger. So I updated minSdkVersion to 21.

  3. I got

    caches/transforms-2/files-2.1/4541b0189187e0017d23bbb0afebd16a/jetified-kotlin-stdlib-common-1.5.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: 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.
    

I tried changing the Gradle version, but I am still getting the same error. How can I solve the incompatible error and add the email and cardholder name in Stripe?

17 Answers

Changing this in file build.gradle solved my problem.

From

ext.kotlin_version = '1.3.50'

to

ext.kotlin_version = '1.6.0'

Or whatever the latest version of Kotlin available and make sure to update Kotlin version on Android Studio as well.

I had this problem in a Flutter project.

In my case, a line for kotlin-gradle-plugin was missing in the Android build.gradle file, so adding ext.kotlin_version = '1.6.10' didn’t fix it.

After adding

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

the error was gone.

Full code section:

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

If you are facing this error in Flutter build for Android then try to change the Kotlin version to

ext.kotlin_version = '1.4.32'

Enter image description here

Firstly, go to settings, and then navigate to plugins. Find the Kotlin plugin and update it.

Next, in gradle files, go to build.gradle (Project: YourApp). Then, change the following code (in buildscript) from:

ext.kotlin_version = '1.3.50'

to the latest version, such as:

ext.kotlin_version = '1.4.32'

To know the latest version, go to settings and the plugins, find the Kotlin plugin, and make sure it is updated. The latest version is under JetBrains.

After following the instructions, your error will be resolved.

Make sure that the Kotlin version of your IDE is the same as the version declared in your gradle.build file.

It was fixed by updating the Kotlin Gradle plugin version.

In the project level build.gradle file, update the following line.

ext.kotlin_version = '1.6.10'

You can find the latest Kotlin Gradle plugin version at Tools / Build tools / Gradle.

What do you need to to solve this?

I was facing this issue since last night. Just navigate through some webpages couldn't get to the exact solution. I finally solved it by these steps:

  • Replace ext.kotlin_version = '1.3.50' with ext.kotlin_version = '1.4.32' in the build.gradle file.
  • Clean project → Build the project with Gradle files → Run

in my case for

The binary version of its metadata is 1.7.1, expected version is 1.5.1

got to (dependencies) inside build.gradle(project) convert from 1.5.x (x) in my case is (20)

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"

to 1.7.10

 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"

Another solution is to downgrade androidx.core:core-ktx library to any compatible version. This one worked for kotlin_version = '1.3.31':

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.3.1'  // The only working for this version (sdk/gradle)
    implementation 'androidx.core:core-ktx:1.0.2' // The only working for this version (sdk/gradle)
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2' // higher versions require min-sdk >= 26
    ...
}

Android SDK: compileSdkVersion 30 and minSdkVersion 19.

Gradle build Tool: com.android.tools.build:gradle:3.3.1.

Just go to file build.gradle (Project: yourProjectName).

Change

plugins {
  ...

  id 'org.jetbrains.kotlin.android' version '1.5.x' apply false

  ...
}

(1.5.x means x version number at your case, such as 1.5.1.)

To

plugins {
  ...

  id 'org.jetbrains.kotlin.android' version '1.7.10' apply false

  ...
}

It works in my case...

Most of the answers here seem to revolve around projects that use Gradle.

I randomly encountered this problem in IntelliJ IDEA that that was compiling and running a Maven project just fine 5 minutes before - no configuration changes. I introduced a new exception class and this problem popped up.

I tried invalidating caches and restarting, which didn't resolve the issue - however, disabling and re-enabling the Kotlin plugin resolved the issue.

I have faced this error in IntelliJ IDEA with a Maven project. The solution is about to turn off Kotlin plugin in IntelliJ IDEA if you are not using Kotlin in your project.

Go to:

Menu File → Settings → Plugins

And turn off the Kotlin plugin by click on the checkbox. See here:

Enter image description here

Using Flutter, it was fixed by:

  • Updating Android Studio packages, specially the Kotlin plugin.

  • Get the last Kotlin plugin version Nbr from Gradle - Plugin and versions. For now it's 1.6.10.

  • Update <Your_project_name_folder>\android\build.gradle file by replacing the old Kotlin version by the new one you got from the web site above.

    ext.kotlin_version = '<The_new_version_Nbr>' in my case ext.kotlin_version = '1.6.10'

  • Restart Visual Studio Code.

You're done.

I faced the same problem in Flutter and I fixed it by going to: File > Settings > Plugins as @Muzzamil said and I checked for the version of Kotlin in my IDE and simply replaced the value in ext.kotlin_version (that is 1.6.10) by that value

ext.kotlin_version = '1.6.10'

I have the set minsdk 24 and restart the Android Studio, its working fine.

project build.gradle:

ext.kotlin_version = '1.6.10'

app/build.gradle:

  dependencies {
   //  classpath 'com.android.tools.build:gradle:7.1.2'
   //  classpath "org.jetbrains.kotlin:kotlin-gradle- plugin:$kotlin_version"
   }

But after changes ext.kotlin_version to lower this warning stay but the red warning is gone

enter image description here

In my case, the solution was:

  • Updating Android Studio packages, specially Kotlin plugin.

    Get the last Kotlin plugin version number from Gradle - Plugin and versions. For me it's 1.6.10. You can get the last version here: https://plugins.jetbrains.com/plugin/6954-kotlin

  • Update <Your_project_name_folder>/android/build.gradle file by replacing the old kotlin version by the new one you got from the web site above. In my case ext.kotlin_version = '1.6.10'

  • Update the file <Your_project_name_folder>/android/gradle/wrapper/gradle-wapper.properties

    Change the version of the distributionUrl properti:

    from https://services.gradle.org/distributions/gradle-5.6.2-all.zip

    to https://services.gradle.org/distributions/gradle-6.9-all.zip

    To see about this last point: https://stackoverflow.com/a/67470309/15330197

Related