I have two multiplatform projects which I upgraded...
# compose-android
d
I have two multiplatform projects which I upgraded to Kotlin 1.9.0, Compose 1.4.3, Gradle 8.0.0. I haven't specified the Compose Compiler version in any of the two. But when I compile the Android app, one compiles successfully and the other one gives me this error:
Copy code
> Task :androidApp:compileDebugKotlin FAILED
e: This version (1.3.2) of the Compose Compiler requires Kotlin version 1.7.20 but you appear to be using Kotlin version 1.9.0 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
I am very puzzled, as I have never specified this 1.3.2 Compose Compiler version anywhere. I even searched for the string "1.3.2" in the whole project, but it's nowhere.
j
It is likely the default version specified by your version of the Android Gradle plugin in use
I'm going to assume the
androidApp
Gradle module applies the
com.android.application
plugin. Therefore, you need to explicitly specify the AndroidX Compose compiler version 1.5.0 or today's 1.5.1 version which are the two which work with Kotlin 1.9
See https://developer.android.com/jetpack/androidx/releases/compose-kotlin both for how to do it, and also for the version mapping you can use in the future to ensure you have a compatible AndroidX Compose compiler.
👍 1
d
Strange thing is that, without specifying the Compose Compiler version, one of the two projects compiles correctly and one doesn't.
j
Do they use different AGP versions?
d
same 8.0.0
Actually, I just cleaned the other project, and it doesn't compile either! So, I am going to specify the Compose Compiler version in both 👍
Is there a reason why the Compose Compiler version is only specified in Android, and not in the other platforms?
j
You can specify it through the JetBrains Compose Gradle plugin extension as well
Note that they have their own versioning which mostly matches
d
yes, it looks like on the other platforms it's not needed to specify the Compose Compiler version
j
It definitely can be
You are likely just using a version of JetBrains Compose Gradle plugin which happens to default to a JetBrains Compose compiler which supports Kotlin 1.9. But if you were trying to support Kotlin 1.9 a week ago with JetBrains Compose UI 1.4.2 you would have had to specify the JetBrains Compose compiler 1.5.0 version explicitly to make it work.
d
Yes, you are right 👍 I have just personally always avoided to specify a Compose Compiler version, because I tend to move to the next versions of Kotlin/Compose only when they are fully compatible with each other.
j
Older runtimes should always work with newer versions of Kotlin through a new Compose compiler. If this didn't work, the entire library ecosystem would have to recompile everything on every new release of Kotlin.
We always specify the Compose compiler version explicitly for both AGP usage and Compose Gradle plugin usage, and we do so through an entry in the version catalog despite only using the version component because that means tools like Renovate can update the Compose compiler to the latest as soon as they're available. Both Google and JetBrains are very slow at releasing the larger Compose runtime library suites, whereas the Compose compiler is released more frequently. This way, we aren't blocked by their speed (or lack thereof).
👍 1
👍🏾 1
Moreover, it shortens their feedback loop such that if there happens to be an actual problem, it can be addressed and included in another Compose compiler release before the gigantic Compose runtime library releases. Because if you only upgrade then, you now have to wait weeks to see the fix (and if you're only implicitly getting the compiler version you probably have to wait months). This can leave you very far behind.
d
It makes sense. It's definitely a good idea to specify/update the Compose Compiler version.
560 Views