For Gradle, use the Compose Compiler Gradle plugin to set up and configure Compose.
Set up with Gradle version catalogs
Set up the Compose Compiler Gradle plugin:
- In the
libs.versions.tomlfile, remove any reference to the Compose Compiler. In the
versionsandpluginssections, add the new dependency:[versions] kotlin = "2.3.21" [plugins] org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } // Add this line compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }In the project's root
build.gradle.ktsfile, add the following to thepluginssection.plugins { // Existing plugins alias(libs.plugins.compose.compiler) apply false }In each module that uses Compose, apply the plugin:
plugins { // Existing plugins alias(libs.plugins.compose.compiler) }
The project should now build and compile if it was using the default set up. If it had configured custom options on the Compose compiler, follow the next section.
Set up the Compose Compiler without Gradle version catalogs
Add the plugin to build.gradle.kts files associated with modules where Compose
is used:
plugins {
id("org.jetbrains.kotlin.plugin.compose") version "2.3.21" // this version matches your Kotlin version
}
Add the classpath to your top-level project build.gradle.kts file:
buildscript {
dependencies {
classpath("org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:2.3.21")
}
}
Configuration options with the Compose Compiler Gradle Plugin
To configure the Compose compiler using the Gradle plugin, add the
composeCompiler block to the module's build.gradle.kts file at the top
level:
android { … }
composeCompiler {
reportsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
}
For the full list of available options, see the documentation.
Set up Compose dependencies
Always use the latest Compose BOM version: 2026.06.00.
Set the compose flag to true inside the Android BuildFeatures to
enable Compose functionality in Android Studio.
Add the following definition to your app's build.gradle file:
Groovy
android {
buildFeatures {
compose true
}
}
Kotlin
android {
buildFeatures {
compose = true
}
}
Add the Compose BOM and the subset of Compose library dependencies:
Groovy
dependencies {
def composeBom = platform('androidx.compose:compose-bom:2026.06.00')
implementation composeBom
androidTestImplementation composeBom
// Choose one of the following:
// Material Design 3
implementation 'androidx.compose.material3:material3'
// or skip Material Design and build directly on top of foundational components
implementation 'androidx.compose.foundation:foundation'
// or only import the main APIs for the underlying toolkit systems,
// such as input and measurement/layout
implementation 'androidx.compose.ui:ui'
// Android Studio Preview support
implementation 'androidx.compose.ui:ui-tooling-preview'
debugImplementation 'androidx.compose.ui:ui-tooling'
// UI Tests
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
// Optional - Add window size utils
implementation 'androidx.compose.material3.adaptive:adaptive'
// Optional - Integration with activities
implementation 'androidx.activity:activity-compose:1.13.0'
// Optional - Integration with ViewModels
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.10.0'
// Optional - Integration with LiveData
implementation 'androidx.compose.runtime:runtime-livedata'
// Optional - Integration with RxJava
implementation 'androidx.compose.runtime:runtime-rxjava2'
}
Kotlin
dependencies {
val composeBom = platform("androidx.compose:compose-bom:2026.06.00")
implementation(composeBom)
androidTestImplementation(composeBom)
// Choose one of the following:
// Material Design 3
implementation("androidx.compose.material3:material3")
// or skip Material Design and build directly on top of foundational components
implementation("androidx.compose.foundation:foundation")
// or only import the main APIs for the underlying toolkit systems,
// such as input and measurement/layout
implementation("androidx.compose.ui:ui")
// Android Studio Preview support
implementation("androidx.compose.ui:ui-tooling-preview")
debugImplementation("androidx.compose.ui:ui-tooling")
// UI Tests
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-test-manifest")
// Optional - Add window size utils
implementation("androidx.compose.material3.adaptive:adaptive")
// Optional - Integration with activities
implementation("androidx.activity:activity-compose:1.13.0")
// Optional - Integration with ViewModels
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.10.0")
// Optional - Integration with LiveData
implementation("androidx.compose.runtime:runtime-livedata")
// Optional - Integration with RxJava
implementation("androidx.compose.runtime:runtime-rxjava2")
}
compileSdk and Android Gradle Plugin compatibility
Compose library releases continually adopt the latest compileSdk versions to
provide access to the latest Android features. Newer compileSdk versions
require newer versions of Android Gradle Plugin, so adopting new Compose
releases also requires projects to adopt new versions of the Android Gradle
Plugin. We recommend keeping your project's compileSdk up to date with the
latest released versions. compileSdk is unrelated from targetSdk.
For example, starting with Compose 1.12.0, projects are required to use
compileSdk 37 and Android Gradle Plugin (AGP) 9.
To check which version of AGP is supported for different API levels, see the Android Gradle plugin API level support documentation.