Compose Kotlin Version Compatibility
Problem Statement
When using Jetpack Compose in Android Studio, you may encounter this error:
This version (1.3.2) of the Compose Compiler requires Kotlin version 1.7.20 but you appear to be using Kotlin version 1.8.0 which is not known to be compatible. Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
This occurs when your Compose compiler and Kotlin versions are mismatched. Jetpack Compile requires specific Kotlin versions to function correctly, and using incompatible pairings causes this build failure.
Solutions
1. Match Compose Compiler with Kotlin Version
Ensure your kotlinCompilerExtensionVersion
aligns with the Compose-Kotlin compatibility chart. Find your Compose version in the table below and use its corresponding Kotlin version.
// build.gradle (module-level)
android {
composeOptions {
kotlinCompilerExtensionVersion = "1.4.8" // Must match your Kotlin version
}
}
// build.gradle (project-level)
plugins {
id 'org.jetbrains.kotlin.android' version '1.8.22' // Match compatible version
}
2. Use Compose Compiler Plugin (Kotlin 2.0.0+)
For projects using Kotlin 2.0.0 or newer:
- Add the Compose compiler plugin in your project-level build file
- Remove
composeOptions
from module-level build files - Apply the plugin in your module
// build.gradle.kts (project-level)
plugins {
id("org.jetbrains.kotlin.plugin.compose") version "2.0.20" apply false
}
// build.gradle.kts (module-level)
plugins {
id("org.jetbrains.kotlin.plugin.compose")
}
3. Verify Multiplatform Configurations
For KMM projects, double-check Compose flags aren't accidentally enabled in shared modules:
// REMOVE incorrect multiplatform configuration:
buildFeatures {
compose = true // This shouldn't be here in multiplatform modules
}
Compatibility Reference
Keep these frequently updated pairings handy:
Compose Compiler Version | Kotlin Version |
---|---|
1.5.12 | 1.9.23 |
1.5.8 | 1.9.22 |
1.5.7 | 1.9.21 |
1.5.0 | 1.9.0 |
1.4.8 | 1.8.22 |
1.4.0 | 1.8.0 |
1.3.2 | 1.7.20 |
TIP
Always verify the latest compatibility at the official Compose-Kotlin Compatibility Map.
Suppressing Version Checks (Not Recommended)
While you can forcibly disable the version check, this risks runtime crashes and unstable behavior:
kotlinOptions {
freeCompilerArgs += [
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true"
]
}
DANGER
Only use suppression as a temporary workaround if you fully understand the risks. Mismatched versions may cause subtle compiler bugs or runtime failures.
Key Takeaways
- Prefer matching versions using the compatibility table
- Migrate to Compose plugin for Kotlin 2.0+ projects
- Verify configurations in multiplatform modules
- Avoid suppressing checks unless absolutely necessary