406

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?

3

45 Answers 45

551

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.

Sign up to request clarification or add additional context in comments.

8 Comments

This line of code is in this file: "flutter_app/android/build.gradle"
minSdkVersion 24
For a detailed explanation of what is happening here see this answer stackoverflow.com/a/74425347/114549
It's not good to set the latest version as it may not be compatible with your current version of gradle. Versions of gradle and kotlin must macth to avoid issues as detailed here: jetbrains.com/help/kotlin-multiplatform-dev/…
This line of code for me is in this file: settings.gradle Changed from id "org.jetbrains.kotlin.android" version "1.7.10" apply false To id "org.jetbrains.kotlin.android" version "1.9.10" apply false
|
357

Although this question has been answered, I think it's worth explaining what is happening

For the example:

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

The expected version is the Kotlin for kotlin-gradle-plugin

The binary version is what is downloaded (or previously compiled) for com.android.tools.build:gradle

<project_dir>/android/build.gradle

buildscript {
    ext.kotlin_version = '1.5.20' // <= expected version is 1.5.1
}

dependencies {
    classpath 'com.android.tools.build:gradle:7.3.1' // downloads 1.7.1 Metadata
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // <= 1.5.20 used here
}

Why is this Happening So Much?

  1. The user updates the Kotlin version of the plugin to match the IDE version per the warning.

    Warning from Android Studio to match Kotlin Versions

  2. The user updates the android build tools gradle plugin per the warning

    Warning about android build tools

This is the WRONG version!

Now you don't have any warnings, but the version suggested is 7.1.3 which is not the latest. (I don't know why it suggests this older version) 7.3.1 is currently the latest and is meta data 1.7.1, so it will match the Kotlin version of 1.7.20 (which is also metadata 1.7.1)

What else could be wrong?

Due to caching, Gradle may be using an older dependency before you updated. To start clean:

  1. delete the ~/.gradle/cache directory
  2. delete the android/.gradle directory
  3. delete the project_dir/build dir
  4. ensure the android/gradle/gradle-wrapper.properies has the correct distributionUrl (currently distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip)
  5. from project_dir do flutter build apk

NOTE: your dependencies may need to be updated if their com.android.tools.build:gradle version is too old. Alternatively, both the Kotlin and tools:gradle versions can be downgraded to compatible version that match metadata (although Android Studio will warn for that not matching the IDE Kotlin version)

How to prevent this from happening again?

12 Comments

ensuring the version and checking the list urls for the correct versions did the trick. was on 1.5.30 for some reason instead of 1.7.2
So, it is a version checking issue of AGP. AGP should validate the kotlin version the project current using is whether compatible or not.
I was also getting this issue in case of Google Captcha V3 SDK integration below solution work for me ext.kotlin_version = "1.7.20" classpath "com.android.tools.build:gradle:7.3.1" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
this helped me a lot. I had to open the Android folder in android studio, this made a sync automatically for me.
How would I find out that gradle:7.3.1 will download version 1.7.1 Metadata?
|
72

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

Comments

30

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

2 Comments

If 1.4.32 doesn't work try 1.6.0
How were you using VSCode to build Android apps?
24

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.

3 Comments

My current project is very old. And exactly 1.4.32 version allowed me solve the issue. Updating to newer versions produce some problems.
Better, see what they recommend here: docs.flutter.dev/release/breaking-changes/kotlin-version.
Update plugins resolve the issue, thank you !
20

In such case, read the build.gradle (:project) carefully. I overlooked the warning that's why I was getting this problem.

Initially my settings of build.gradle (:project) was

plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}

As I was getting this error

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.

So I changed this setting in the build.gradle (:project) to the following:

plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
}

Hope it solves your problem.

Comments

19

[2025] Solution with Explanation

In Oct 2024, a lot of the answers got a bit outdated for my case. Due to mixing up in the process, I lost some time. But it is actually very easy. Hence, I'll sum up what will actually work with explanation.

[Normally, you only need THIS FIRST PART]

First, let's look at what Flutter is suggesting. Flutter suggestion for fixing the error

For older versions than Flutter 3.19, you'd work on build.gradle file, which is the case in most of the answers.

But most likely you are using a newer version, so you must work on primarily settings.gradle. But... If you have already mixed up things like me you need to make sure to fix a few things.

The error says Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. > here, the binary version is what is written in your settings.gradle file for kotlin, and the expected version is associated with your AGP version i.e. your AGP version is not compatible with your kotlin version. You can find the version compatibility here with AGP vs Kotlin (KGP).

Now, open your settings.gradle file, and put the versions (that you want and compatible with each other) here [NOTE: I have used a different version than my error message (as per my interest) - 2.0.20 for Kotlin, and 8.1.1 for AGP] -

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

[You may need THIS PART if your other settings are messed up]

Now, you need to make sure that you don't overwrite or mix up these values in other places.

  • REMOVE (if present) this block from project gradle (android/build.gradle). It is not required in newer version of Flutter or android project. remove buildscript block
  • Go to app gradle (android/app/build.gradle). Make sure these 3 numbers match, if present (it threw an error until I matched them), otherwise ignore. I used Kotlin's JRE version 17 as jvmTarget. jvmTarget
  • IMPORTANT open graddle-wrapper.properties > MAKE SURE distributionUrl has the same version number as AGP. In my case, it's 8.1.1. distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
  • Now, clean the gradle caches (usually C:\Users\NAME\.gradle\caches). Close your IDE if required.
  • Open project/android folder in Android Studio. Make sure you have Kotlin plugin installed on it (Settings > Plugins). Let Android Studio prepares the project. It will automatically download AGP and related files. If you have changed any project settings in File > Project Structure, make sure they are undone, and keep the defaults. Click the elephant icon at the top: Sync Project with the Gradle Files. It should complete the build normally. You can ignore AGP upgrade notification, if you are confident that you chose the compatible AGP in the earlier stage.
  • From terminal, flutter clean > flutter pub get > flutter run or flutter build apk --build-name=1.0 --build-number=1 --no-tree-shake-icons. These will complete the build normally as well.

2 Comments

If anyone sees it in 2025, please continue with this answer. right solution
Text ist better the screenshots. Because text allows to copy paste and screenshots do not.
17

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

1 Comment

This is not necessary. The IDE should be backwards compatible with all kotlin versions
16

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.

Comments

15

Changed the Project build gradle to

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

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

Comments

13

in my case for

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

go 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"

Comments

9

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 projectBuild the project with Gradle filesRun

Comments

6

Go to the file build.gradle, change the version of kotlin. In case in my flutter project I opened build.gradle and changed

`ext.kotlin_version = '1.5.30'` 

to ext.kotlin_version = '1.6.0'

Here

buildscript {
ext.kotlin_version = '1.6.0'

repositories {
    google()
    jcenter()
}

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

}


Then save and do

flutter clean and flutter run.

Works fine for me.

Comments

6

For macOS you can

rm -r $HOME/.gradle/caches/

or you can invalidate caches

File >> Invalidate caches

1 Comment

Invalidate cache did it for me
5

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...

Comments

5

go to Build.gradle (Project : NAME_PROJECT) and set code id 'org.jetbrains.kotlin.android' version '1.8.0' apply false in plugins """ clear any code out of plugin """

2 Comments

This is the only way to let it works on gradle lately for my case. Thank you!
I also thank you for reading my message! I hope you always succeed in programming
4

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.

Comments

4

Apparently there might be a vast variety of reasons of this fault. In my case, when I even did not use Kotlin but Java, the problem was I updated Firebase library version to the newest one. I switched from:

implementation 'com.google.firebase:firebase-analytics:21.2.2'

to:

implementation 'com.google.firebase:firebase-analytics:21.5.0'

an it caused analogous fault. I switched back to the old version and it worked.

"Funny" fact was that fault popped out only when I build apk file. When I build aab for Google Play everything went smooth.

Just for information for others who will check this thread.

Comments

3

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.

Comments

3

Updated solution for flutter 3 :

Edit this line to set your kotlin to latest version :

id "org.jetbrains.kotlin.android" version "1.9.22" apply false

in file : project/android/settings.gradle.

The latest koltin version can be find here : https://kotlinlang.org/docs/releases.html#release-details

Comments

2

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.

Comments

2

Kotlin config is a nightmare, I have two project, a 100% Java and other with Kotlin, wow, is a huge difference. (And I don't talk about Flutter, it is a similar nightmare). Well, many noise with that. At least for me worked the next steps:

  1. running the suggested Kotlin migrations from the IDE
  2. invalidate caches

And I added the kotlin-bom like this:

dependencies {
    ...
    implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    ...
}

in the main build.gradle file:

buildscript {
    ext.kotlin_version = '1.7.20'
    
    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

And also update the target to:

android {
    compileSdkVersion 34
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 34
        ...
    }
}

1 Comment

At least you can wake up from a nightmare
2

For me the trick was to update the android library version as well along with kotlin version

Before

plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.0' apply false

}

After

plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false

}

Comments

2

I was using 1.92.22 in build gradle

ext.kotlin_version = '1.9.22'

in setting.gradle it was 1.7.2 in plugin when i correct this it work

Comments

1

Many times, the error can arise after a library integration. The integrated library may be compiled using a Kotlin version newer than the one used in your project. In that case, there can be two solutions:

  1. Downgrade the library dependency version.
  2. Upgrade the Kotlin version for your own project to be greater than or equal to the library's Kotlin version.

Comments

1

In my case it was a cryptic reason. It was running out of memory during build, yet wouldn't be explicit about it, instead throwing the exception about incompatible version of Kotlin.

For me, the solution was to change org.gradle.jvmargs=-Xmx1536m to org.gradle.jvmargs=-Xmx2048m in gradle.properties

Comments

1

I had an error like that it said..

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.

Solution I went to pubspec.yaml and find the package that was causing this because for me it happened after adding couple of libraries, you need to test(comment & uncomment) untill you find (it/them), for me it was the latest package url_launcher

url_launcher: ^6.2.5 

I changed it to a specific old version

url_launcher: 6.0.5  
  • Clean project
  • build apk

and it worked!

in my android/settings.gradle

.............
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.7.10" apply false
}

in my android/gradle/wrapper/gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip

in my android/build.gradle

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
}

1 Comment

in my case setting id "org.jetbrains.kotlin.android" version "2.0.0" apply false in setting.grade file works for me
0

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

Comments

0

Please check if you Kotlin version is compatible with compose version. if not, then please make the changes and it should work fine.

Compose Compiler Version Compatible Kotlin Compiler Version

1.3.0 --> 1.7.10
1.3.0-rc01 --> 1.7.10
1.3.0-beta01 --> 1.7.10
1.2.0 --> 1.7.0
1.2.0-rc01 --> 1.6.21
1.2.0-beta03 --> 1.6.21
1.2.0-alpha08 --> 1.6.20
1.1.0 --> 1.6.10
1.1.1 --> 1.6.10
1.1.0-rc031.6.10

Comments

0

I simply download the updated version.

enter image description here

I'm currently using macmini with m1 chip.

Before, the version of my android studio was bumble-bee. Now I've updated to version Giraffe.

Everything works fine after that.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.