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 issueDescribe 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:
- Created 2 years ago
- Reactions:8
- Comments:11 (2 by maintainers)
Top GitHub Comments
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
@JavierStuart we got the similar issue in our project and we applied a workaround:
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: