Issue
As I introduced Jetpack Compose and Room simultaneously for a new app, my Android Studio threw this error.
/***/***/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.7.0/51736992f422993a1e741051bdf3c12801bc1ca1/kotlin-stdlib-common-1.7.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.7.1, expected version is 1.5.1.
When I wrote codes without Room libraries, I didn't get the error. Here is what I tried to solve this problem.
Upgrading Android Studio and Kotlin version
Referred this page: 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
However, I wasn't able to find "ext.kotlin_version = 'xxx'.", so I wrote this code in build.gradle, but wasn't able to solve it.
buildscript { ext { compose_version = '1.1.0-beta01' kotlin_version = '1.7.0' // add this line with '1.7.0' and '1.7.1' } }
Referred another page: https://github.com/square/kotlinpoet/issues/1303
How should I do next to deal with this problem?
Solution
You can try upgrading kotlin to 1.7.10 and compose to 1.3.0. If not worked,try with compose 1.2.0 and kotlin 1.7.0 You can find all compataible versions here.
Also make sure to use same variable for kotlin gradle plugin in project build.gradle.
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Answered By - Gowtham K K
Answer Checked By - Senaida (JavaFixing Volunteer)