Hi, I am upgrading kotlin from 1.6.21 to 1.8.20 an...
# compiler
s
Hi, I am upgrading kotlin from 1.6.21 to 1.8.20 and have set classpath "org.jetbrains.kotlinkotlin gradle plugin$kotlin_version" in dependencies. I am getting below error during compilation: e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-parcelize-runtime/1.8.20/4023f7435cdd59903046f2b4c5161761f9c4d013/kotlin-parcelize-runtime-1.8.20.jar!/META-INF/parcelize-runtime.kotlin_module: 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. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-android-extensions-runtime/1.8.20/9b8227702ceb5f6e4bbbe064a6b2c259682b9d4d/kotlin-android-extensions-runtime-1.8.20.jar!/META-INF/kotlin-android-extensions-runtime.kotlin_module: 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. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.20/e72fc5e03ec6c064c678a6bd0d955c88d55b0c4a/kotlin-stdlib-1.8.20.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: 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. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.20/e72fc5e03ec6c064c678a6bd0d955c88d55b0c4a/kotlin-stdlib-1.8.20.jar!/META-INF/kotlin-stdlib.kotlin_module: 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. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.20/e72fc5e03ec6c064c678a6bd0d955c88d55b0c4a/kotlin-stdlib-1.8.20.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: 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. e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.20/5eddaaf234c8c49d03eebeb6a14feb7f90faca71/kotlin-stdlib-common-1.8.20.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.8.0, expected version is 1.6.0. When I change the kotlin-gradle-plugin version to 1.7.20, the errors are not seen. Can someone please share how to fix this error without downgrading kotlin-gradle-plugin? Thanks in advance
j
A bit of an obvious question, but doesn’t harm to ask 😅: have you tried completely wiping out gradle caches? Maybe some stale dependencies from cache are messing your build. Maybe trying
rm -r .gradle/caches
combined with
./gradlew clean
would help
s
Tried it.But it doesn't fix the issue. In Android studio, under external libraries I see below list which has kotlin and kotlinx from different versions. Would this be the root cause?
j
I think what you can see here is all right since that’s version of
kotlinx-coroutines
which is different than kotlin itself (see repo here with latest 1.7.3)
But I can see in your error log:
Copy code
e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-parcelize-runtime/1.8.20/4023f7435cdd59903046f2b4c5161761f9c4d013/kotlin-parcelize-runtime-1.8.20.jar!/META-INF/parcelize-runtime.kotlin_module: 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.
Which would indicate that you have a version of
kotlin-parcelize
that is expecting different language version. Since kotlin-parcelize is a compiler plugin it one version may require specific Kotlin version to work well (just as you have to bump Kotlin to bump compose) Try bumping kotlin-parcelize as well
s
kotlin-parcelize is already having the version as 1.8.20 in the library list. anything else to be done for this?
j
Have you also bumped AGP (android gradle plugin)? See detailed answer why this is needed
s
Yes. The version of AGP is 7.2.2.Thank you. I will check the links.
Fixed it by further upgrading com.android.tools.build:gradle to 7.4.2. thank you so much for your time.