1

I'm using two modules in my app, one for Android and one for WearOS. Both modules are using Jetpack Compose.

I can build my Android module without any issues using the kotlin-gradle-plugin:1.7.20. If I switch to the Wear module AndroidStudio outputs an error stating that it needs a different version of the kotlin-gradle-plugin. This is the error I'm getting:

This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.7.20 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).

Naturally I tried downgrading my Kotlin version to 1.6.10, this however brings up a totally different issue while trying to build any module:

jetified-savedstate-ktx-1.2.1-api.jar!/META-INF/savedstate-ktx_release.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.

I tried Invalidate caches and restart after changing the version

To conclude:

  • Android module needs version 1.7.20
  • Wear module needs version 1.6.10
  • If I downgrade I receive a different error, which I can't resolve

How would you go about fixing this? As far as I know I cant specify the kotlin-gradle-plugin version on a module basis and it needs to be in the project gradle file. I did not find a way to specify a module for the depedency in the root file like it is implemented with flavors.

BlazeCodeDev
  • 631
  • 1
  • 7
  • 27
  • Maybe, you can try to upgrade compose version to `1.3.2`? – Javlon Apr 18 '23 at 20:50
  • I'm running `wear_compose_version = '1.2.0-alpha08'` which is the newest, other than that I'm using `androidx.compose:compose-bom:2023.04.00` in both modules – BlazeCodeDev Apr 19 '23 at 10:09
  • Does this answer your question? [This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.5.31](https://stackoverflow.com/questions/72537582/this-version-1-1-1-of-the-compose-compiler-requires-kotlin-version-1-6-10-but) – Sergei Kozelko Apr 20 '23 at 06:54
  • have you considered trying multiple gradle sourcesets https://stackoverflow.com/questions/45800829/gradle-how-to-specify-two-sourcesets-of-library-and-add-dependency-in-project. Use different versions of the kotlin-gradle-plugin for your Android and WearOS. Or use Gradle properties to specify the versions of the dependencies, and then reference those properties in your module dependencies in gradle.properties androidKotlinVersion=1.7.20 wearKotlinVersion=1.6.10 – shabby Apr 20 '23 at 06:56

1 Answers1

2

Compose compiler version is closely tied to kotlin version. Since you cannot change kotlin version, you need to change compose compiler version. Right now it is 1.1.1, change it to 1.3.2.

Note: compose compiler is not the same thing as compose. Their versioning is independent specifically for this reason.

Sergei Kozelko
  • 691
  • 4
  • 17
  • Thanks I overlooked the `kotlinCompilerExtensionVersion` parameter in the `wear` gradle file, I don't have that in my `app` module – BlazeCodeDev Apr 20 '23 at 10:53