
Posted by Ben Trengrove – Developer Relations Engineer, Nick Butcher – Product Manager for Jetpack Compose
We are pleased to announce that with the upcoming release of Kotlin 2.0, the Jetpack Compose compiler will move to the Kotlin repository. This means that a matching Compose compiler is released alongside each release of Kotlin. You no longer have to wait for a corresponding Compose compiler release before upgrading the Kotlin version in your Compose app. The Compose team at Google will continue to be responsible for the development of the compiler and will work closely with JetBrains, our co-founders of the Kotlin Foundation. The Compose compiler version now always matches the Kotlin version. The compiler version therefore jumps to 2.0.0.
To simplify the installation of Compose, we are also releasing a new Compose Compiler Gradle plugin that allows you to configure the Compose compiler with a type-safe API. The version control of the Compose Compiler Gradle plugin matches that of Kotlin and is available from Kotlin 2.0.0.
To migrate to the new plugin, add the Compose Compiler Gradle plugin dependency to the plugins section of your Catalog of the Gradle version:
[versions]
kotlin = "2.0.0"
[plugins]
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
// Add the Compose Compiler Gradle plugin, the version matches the Kotlin plugin
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
Add the plugin to the top-level Gradle file of your project:
plugins {
// Existing plugins
alias(libs.plugins.compose.compiler) apply false
}
Then, in modules that use Compose, apply the plugin:
plugins {
// Existing plugins
alias(libs.plugins.compose.compiler)
}
The kotlinCompilerExtensionVersion no longer needs to be configured in composeOptions and can be removed.
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
If necessary, you can now add a top-level section to the same Gradle file to configure options for the Compose compiler.
android { ... }
composeCompiler {
enableStrongSkippingMode = true
}
You can currently reference the Compose Compiler directly in your build installation, instead of using AGP to apply the Compose Compiler plugin. If so, keep in mind that the maven artifacts will also change:
Old |
New |
androidx.compose.compiler:compiler |
org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable |
androidx.compose.compiler: Compiler hosted |
org.jetbrains.kotlin:kotlin-compose-compiler-plugin |
See this for an example of this migration pull request.
For more information about migrating to the new Compose compiler artifact, including instructions for non-version catalog settings, see our updated documentation.