303

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?

Ovidiu Uşvat
  • 701
  • 1
  • 6
  • 29
Karthy Sbk
  • 3,153
  • 2
  • 8
  • 7
  • 1
    Regarding the Kotlin build error, do either of these previous answers help? https://stackoverflow.com/a/67470309 https://stackoverflow.com/a/35170452 – Nolan H May 26 '21 at 13:17
  • Does this answer your question? ["Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16"](https://stackoverflow.com/questions/67448034/module-was-compiled-with-an-incompatible-version-of-kotlin-the-binary-version) – Troy May 21 '22 at 15:32
  • 2
    I experienced this issue while building an app that used my library. It appeared to be caused by an update of the Kotlin Gradle plugin from 1.4.32 to 1.5.31. To fix this, I changed the languageVersion and apiVersion to '1.4' and built a new version of the library. Not directly related to the client issue described here, but possibly useful for library maintainers. – fejd Jul 04 '22 at 13:40

31 Answers31

494

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mohamed Arafa
  • 5,108
  • 1
  • 8
  • 14
171

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?

aaronvargas
  • 12,189
  • 3
  • 52
  • 52
  • 6
    should be the accepted answer, best answer here – alfietap Dec 29 '22 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 – Chrismisballs Jan 12 '23 at 06:56
  • 1
    How about that? This IS the CORRECT ANSWER. Thanks guy!! – Abner Escócio Feb 22 '23 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 07 '23 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" – Yogesh Srivastava Apr 19 '23 at 09:50
  • Actually we also need to consider which dependency failing this, in my case I need to lower down the version of that particular dependency. – Mohit Dixit Aug 16 '23 at 03:56
62

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"
    }
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
kashlo
  • 2,313
  • 1
  • 28
  • 39
29

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
MYJ World
  • 820
  • 1
  • 5
  • 16
  • 2
    My current project is very old. And exactly 1.4.32 version allowed me solve the issue. Updating to newer versions produce some problems. – antaki93 May 25 '22 at 12:22
  • Better, see what they recommend here: https://docs.flutter.dev/release/breaking-changes/kotlin-version. – Daniel Porteous May 29 '22 at 02:17
16

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

user14604774
  • 169
  • 2
15

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
UdaraWanasinghe
  • 2,622
  • 2
  • 21
  • 27
13

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"
    }
}
Mehul Kabaria
  • 6,404
  • 4
  • 25
  • 50
kaushal Kishore
  • 131
  • 1
  • 3
10

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"
Ziaad Aboelela
  • 359
  • 2
  • 6
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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
9

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.

Raj Kanchan
  • 450
  • 6
  • 11
5

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.

Confiance
  • 706
  • 5
  • 7
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ibrahim.H
  • 1,062
  • 1
  • 13
  • 22
3

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Md. Enamul Haque
  • 926
  • 8
  • 14
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
silver daymon
  • 149
  • 1
  • 5
2

For macOS you can

rm -r $HOME/.gradle/caches/

or you can invalidate caches

File >> Invalidate caches
1

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

Apoorv Pandey
  • 2,118
  • 2
  • 11
  • 13
1
This works for me

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"
    }
}
RS Bind
  • 31
  • 3
1

Add

buildscript {
    ext {
      kotlinVersion = "1.6.0"
     ...
    }
  ...
}  

in android/build.gradle

More info here here

Sahil bakoru
  • 393
  • 1
  • 4
  • 10
1

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

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
0

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'
0

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

Dinesh2510
  • 101
  • 1
  • 5
0

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

Harish
  • 1
  • 1
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

Add classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0" this in your build.gradle sync and restart studio, it will work. It worked for me.

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        def nav_version = "2.5.3"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0"
        classpath("androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version")
        classpath 'com.google.gms:google-services:4.3.15'

    }
}
0

another posibility for updating kotlin version to another stable and appropiate for your flutter version is to create, in other folder, a new flutter project. In that project, go to the file android\build.gradle And check the version of this project:

buildscript {
    ext.kotlin_version = '1.7.10'    <-- Check this version vs your version
    repositories {
        google()
        mavenCentral()
    }

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

Change your previous version to this new version and that must run correctly.

0

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.
Devansh Maurya
  • 832
  • 12
  • 11
-1

I upgraded the android studio version to the latest and that resolved the issue

Ann
  • 1
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 21 '22 at 01:42
  • 1
    This is not an answer, [ask] – Jorgesys Mar 01 '23 at 22:41
-1

disabling kotlin plugin from intellij plugin section, worked for me enter image description here

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 04 '23 at 15:08
-2

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 FileSettingsPlugins

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

Enter image description here

Muzzamil
  • 2,823
  • 2
  • 11
  • 23
  • I was working on a Java project that reported the error. This step resolved it for me. – IcedDante Jan 27 '22 at 19:41
  • @IcedDante Glad to hear. Yes , this solutions works if you are not using Kotlin. – Muzzamil Jan 28 '22 at 07:59
  • 5
    Do not try this now.... Now I've to reinstall android studio Missing essential plugins: com.android.tools.design org.jetbrains.android Please reinstall Android Studio from scratch. – mr.volatile Jun 27 '22 at 09:15
  • @mr.volatile This solution is applicable for Intellij idea. I have mentioned it in my answer as well (if you’re not using kotlin) – Muzzamil Jun 29 '22 at 07:53