question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.

See original GitHub issue

Describe the bug Hi, I’ve recently switched to kotlin 1.6.10 and started getting this error messages from my gradle :buildSrc:compileKotlin: /Users/<me>/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-serialization/1.6.10/4052dd14b5f3264b5d91598f6db4a7b5983cf9cf/kotlin-serialization-1.6.10.jar!/META-INF/kotlin-serialization.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2. and /Users/alexeyglushkov/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-serialization/1.6.10/4052dd14b5f3264b5d91598f6db4a7b5983cf9cf/kotlin-serialization-1.6.10.jar!/META-INF/kotlinx-serialization-compiler-plugin.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.

With kotlin 1.5.31 I was able to build my convention plugins without problems.

To Reproduce Checkout this branch https://github.com/soniccat/WordTeacher/tree/serialization-buildsrc-conflict and run ./gradlew :android:assembleDebug.

The main setup is in two files. buildSrc settings file: https://github.com/soniccat/WordTeacher/blob/serialization-buildsrc-conflict/buildSrc/settings.gradle.kts and KMM convention plugin file: https://github.com/soniccat/WordTeacher/blob/serialization-buildsrc-conflict/buildSrc/src/main/kotlin/kmmlib-convention.gradle.kts

Expected behavior The convention plugin compiles without problems as before. You can get the previous version of the code with kotlin 1.5.31 at this commit https://github.com/soniccat/WordTeacher/commit/0ae62bb76ea1be9dd6d60fc0d23a524f68618aca

The current workaround for me is to move serialization dependency out of buildSrc. The code is here https://github.com/soniccat/WordTeacher/commit/a8ef2e35ba80fb042f3532229c87204528a1c179 I moved plugin importing in the KMM shared lib here https://github.com/soniccat/WordTeacher/blob/a8ef2e35ba80fb042f3532229c87204528a1c179/shared/build.gradle.kts

Environment

  • Kotlin version: 1.6.10
  • Library version: 1.3.1
  • Kotlin platforms: JVM
  • Gradle version: 7.1.1
  • IDE version (if bug is related to the IDE): Android Studio Arctic Fox | 2020.3.1 Patch 4, Build #AI-203.7717.56.2031.7935034, built on November 21, 2021
  • Other relevant context: macOS BigSur 11.2.3 (20D91)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
shindenitishcommented, Nov 12, 2022

If you came here to solve a Kotlin incompatibility issue for ReactNative in November 2022, try once: https://github.com/facebook/react-native/issues/35210

4reactions
nullscommented, Jun 16, 2022

@JavierStuart we got the similar issue in our project and we applied a workaround:

plugins {
    // workaround https://github.com/gradle/gradle/issues/16345
    `kotlin-dsl`.version("2.3.3")
}

It upgraded embedded version of kotlin to 1.6.x and allows to work with 1.7.0, but it leads to warning message during a build:

This version of Gradle expects version '2.1.7' of the `kotlin-dsl` plugin but version '2.3.3' has been applied to project ':buildSrc'. Let Gradle control the version of `kotlin-dsl` by removing any explicit `kotlin-dsl` version constraints from your build logic.
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Module was compiled with an incompatible version of Kotlin ...
"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" ; 1....
Read more >
[Solved] Module was compiled with an ... - Flutter Campus
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...
Read more >
incompatible version of kotlin. the binary version of its ...
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.0.
Read more >
Class 'kotlin/Unit' was compiled with an incompatible version ...
The binary version of its metadata is 1.0.1, expected version is 1.1.0.
Read more >
Android App build error - I have no idea what to do
The binary version of its metadata is 1.6.0, expected version is 1.4.1. ... Module was compiled with an incompatible version of Kotlin.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found