Updating Compose compiler
The Compose compiler is supplemented by a Gradle plugin, which simplifies setup and offers easier access to compiler options. When applied with the Android Gradle plugin (AGP), this Compose compiler plugin will override the coordinates of the Compose compiler supplied automatically by AGP.
The Compose compiler has been merged into the Kotlin repository since Kotlin 2.0.0. This helps smooth the migration of your projects to Kotlin 2.0.0 and later, as the Compose compiler ships simultaneously with Kotlin and will always be compatible with Kotlin of the same version.
To use the new Compose compiler plugin in your project, apply it for each module that uses Compose. Read on for details on how to migrate a Compose Multiplatform project. For a Jetpack Compose project, refer to the migration guide.
Migrating a Compose Multiplatform project
Starting with Compose Multiplatform 1.6.10, you should apply the org.jetbrains.kotlin.plugin.compose
Gradle plugin to each module that uses the org.jetbrains.compose
plugin:
Add the Compose compiler Gradle plugin to the Gradle version catalog:
Add the Gradle plugin to the root
build.gradle.kts
file:
Apply the plugin to every module that uses Compose Multiplatform:
If you are using compiler options for the Jetpack Compose compiler, set them in the
composeCompiler {}
block. See Compose compiler options DSL for reference.
Possible issue: "Missing resource with path"
When switching from Kotlin 1.9.0 to 2.0.0, or from 2.0.0 to 1.9.0, you may encounter the following error:
To resolve this, delete all the build
directories: at the root of your project and in each of the modules.
What's next
See Google's announcement about the Compose compiler moving to the Kotlin repository.
See Compose compiler options DSL for reference.
To migrate a Jetpack Compose app, check out Compose compiler documentation.