跪拜 Guibai
← All articles
Android

AGP 9.0 Upgrade Hits Three Breaking Changes: Built-in Kotlin, Gradle 9.5, and JVM 11

By Android小渣渣 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

AGP 9.0’s built-in Kotlin is the biggest behavioral shift since the plugin DSL itself. Teams that skip the migration steps will hit hard build failures on the first sync, and the required Gradle 9.5 bump means CI pipelines and wrapper scripts need updating in lockstep.

Summary

AGP 9.0 bundles its own Kotlin compiler, so applying the kotlin-android plugin now throws a duplicate-extension error. The fix is to strip the plugin declaration from both module and project build scripts, and to delete any stale Kotlin plugin references from the version catalog. Gradle 8.11.1 is too old for AGP 9.3.1; the wrapper must point to Gradle 9.5.0 or later.

The Kotlin DSL for JVM target also changed. The old `kotlinOptions { jvmTarget = "1.8" }` block is unresolved under the new built-in Kotlin support and must be replaced with `kotlin { compilerOptions { jvmTarget.set(JvmTarget.JVM_11) } }`. Java compatibility flags move from VERSION_1_8 to VERSION_11 to match.

A stray import of `org.jetbrains.kotlin.storage.CacheResetOnProcessCanceled.enabled` — likely left over from an earlier IDE autocomplete — also breaks the build and needs to be removed. After these three changes, the project builds and runs without further issues.

Takeaways
AGP 9.3.1 requires Gradle 9.5.0 or higher; a wrapper still pointing to 8.11.1 will fail.
Built-in Kotlin support means the `org.jetbrains.kotlin.android` plugin must be removed from all build scripts and the version catalog, or the build crashes with a duplicate `kotlin` extension error.
The `kotlinOptions { jvmTarget = "1.8" }` DSL is unresolved under AGP 9.0; replace it with `kotlin { compilerOptions { jvmTarget.set(JvmTarget.JVM_11) } }`.
Java source and target compatibility must move from `VERSION_1_8` to `VERSION_11`.
Delete any accidental imports like `org.jetbrains.kotlin.storage.CacheResetOnProcessCanceled.enabled` that slip into build scripts.
Conclusions

The built-in Kotlin change eliminates a long-standing source of version skew between the Kotlin plugin and AGP, but it also means the Kotlin version is now effectively locked to whatever AGP ships.

Many projects still targeting JVM 1.8 will need to validate that their dependencies and bytecode tooling handle JVM 11 class files, since the upgrade forces the jump in one step.

Concepts & terms
Built-in Kotlin (AGP 9.0)
Starting with AGP 9.0, the Android Gradle plugin bundles its own Kotlin compiler and applies Kotlin support automatically, removing the need to declare the `kotlin-android` plugin separately.
Gradle wrapper
A script and properties file checked into a project that pins the exact Gradle version used for builds, ensuring every developer and CI environment runs the same version.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗