360

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

37 Answers 37

530

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.

4
270

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

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

11
  • 8
    should be the accepted answer, best answer here
    – alfietap
    Dec 29, 2022 at 20:19
  • 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 Jan 12, 2023 at 6:56
  • 2
    How about that? This IS the CORRECT ANSWER. Thanks guy!! Feb 22, 2023 at 14:06
  • So, it is a version checking issue of AGP. AGP should validate the kotlin version the project current using is whether compatible or not.
    – zwh
    Apr 7, 2023 at 11:29
  • 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" Apr 19, 2023 at 9:50
65

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"
    }
}
0
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
  • 1
    If 1.4.32 doesn't work try 1.6.0 Mar 20, 2022 at 8:54
  • How were you using VSCode to build Android apps? Jan 25 at 10:33
22

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.

2
16

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

1
  • 1
    This is not necessary. The IDE should be backwards compatible with all kotlin versions Oct 17, 2022 at 6:04
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.

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

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.

11

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

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
  • This is the only way to let it works on gradle lately for my case. Thank you!
    – Sarith Nob
    Mar 18 at 6:55
  • I also thank you for reading my message! I hope you always succeed in programming Mar 18 at 19:38
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.

4

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

4

For macOS you can

rm -r $HOME/.gradle/caches/

or you can invalidate caches

File >> Invalidate caches
1
  • Invalidate cache did it for me
    – Dika
    Feb 18 at 23:51
3

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.

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.

2

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.

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
  • At least you can wake up from a nightmare
    – Jack
    Feb 18 at 17:03
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.
1

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

0

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

0

solution A failure occurred while executing com.android.build.gradle.internal.tasks

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

0

Has anyone tried changing "environment" setting inside pubspec.yaml? because It worked for me. I just copied one of my recently created projects "environment" setting to my older project.

0

In our case, it was a change in an update to Auth0. In build.gradle we were using a prefix version range:

implementation 'com.auth0.android:auth0:2.+'

Since we are overriding the Kotlin version, we just needed to update the Auth0 version to an exact version to prevent the 6K+ build errors:

implementation 'com.auth0.android:auth0:2.10.1'

0

If this happens on intelliJ go to preferences --> search for kotlin compiler --> update kotlin compiler version to 1.1.15

0

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

}

Not the answer you're looking for? Browse other questions tagged or ask your own question.