[Solved] Module was compiled with an incompatible version of Kotlin

While running the Flutter Android app, you may encounter a "Module was compiled with an incompatible version of Kotlin" or "Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin" error during compiling. See the solution below to solve this error in your Flutter App. 

e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors

e: C:/Users/Hari Pd. Chaudhary/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/META-INF/kotlin-stdlib.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.

e: C:/Users/Hari Pd. Chaudhary/.gradle/caches/transforms-2/files-2.1/77bab1911042ab2c6d5cc0b2e2ee053c/jetified-kotlin-stdlib-common-1.5.10.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.

e: C:/Users/Hari Pd. Chaudhary/.gradle/caches/transforms-2/files-2.1/bd92f9b27f3f577322c07e31476e006e/jetified-core-ktx-1.6.0-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.5.1, expected version is 1.1.15.

OR,

mpl.kt: (127, 21): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

The class is loaded from C:/Users/Hari Pd. Chaudhary/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.31/6628d61d0f5603568e72d2d5915d2c034b4f1c55/kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class

Open android/build.gradle file and increase the version of ext.kotlin_version to a compatible version of Kotlin. In our case, we change:

ext.kotlin_version = '1.3.50'

TO

ext.kotlin_version = '1.4.32'

Please get the Latest version of Kotlin from: https://kotlinlang.org/docs/releases.html#release-details

Your build.gradle file may look like this:

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

Now hit the command below:

flutter clean

Now run your app again.

In this way, you can solve the "Module was compiled with an incompatible version of Kotlin" error in the Flutter App. 

No any Comments on this Article


Please Wait...