Migrating to AGP 9.2.1: Kotlin build errors I hit and how I fixed them
I recently upgraded an Android project to AGP 9.2.1 and ran into a chain of build errors.
Wiki topics:
📱 · Mobile Development
Migrating to AGP 9.2.1: Kotlin build errors I hit and how I fixed them

Image generate using perplexity
I recently upgraded an Android project to **AGP 9.2.1** and ran into a chain of build errors.
In my case, the project was a very small app, so there might be more issues if the project setup is complicated.
Each one pointed to a different part of the new Kotlin/Gradle setup, and fixing them one by one made the migration much clearer.
Why this happened
AGP 9 introduces built-in Kotlin support that changes the old plugin setup (org.jetbrains.kotlin.android).
- 🛑
kapt, andkotlinOptionsno longer work the same way.
Error 1: Cannot add extension with name kotlin
Cannot add extension with name 'kotlin', as there is an extension already registered with that name.
The fix was to remove the Kotlin Android plugin from the module and
any root-level declarations that still applied it.
AGP 9 already provides Kotlin support, so applying the old plugin causes a duplicate kotlin extension.
Fix
plugins {
id("com.android.application")
// remove: id("org.jetbrains.kotlin.android")
}
Error 2: org.jetbrains.kotlin.kapt is not compatible with built-in Kotlin support
- After removing the Kotlin Android plugin, the next failure came from
**kapt**
The 'org.jetbrains.kotlin.kapt' plugin is not compatible with built-in Kotlin support.
Android’s migration guide recommends moving to KSP,
or using com.android.legacy-kapt only as a temporary fallback.
Fix
- After removing
**kapt, we need to update the affected libraries. In my case, only `Hilt** was affected, so I updated it with theKSP`
plugins {
//....
// Remove KAPT
kotlin("kapt")
// Add KSP
id("com.google.devtools.ksp")
}
// dependencies
dependencies {
// kapt(libs.hilt.compiler)
ksp(libs.dagger.hilt.compiler)
// ...
}
Error 3: Unresolved reference: kotlinOptions
- Once kapt was out of the way, the build hit another issue 🤯
Unresolved reference 'kotlinOptions'
That’s because AGP 9 built-in Kotlin uses the new Kotlin compiler options DSL
instead of the old android.kotlinOptions {} block.
The Android migration doc says to move those settings to
kotlin { compilerOptions { ... } }.
Fix
// Old way
android {
kotlinOptions {
jvmTarget = "17"
}
}
// New way
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
What I learned
In addition to a version bump, AGP 9 changes how Kotlin is built into Android.
References
[embed]
메타데이터
- post_id
- 1565bb36b96f
- slug
- migrating-to-agp-9-2-1-kotlin-build-errors-i-hit-and-how-i-fixed-them-1565bb36b96f
- url
- https://medium.com/@navczydev/migrating-to-agp-9-2-1-kotlin-build-errors-i-hit-and-how-i-fixed-them-1565bb36b96f
- canonical_url
- https://medium.com/@navczydev/migrating-to-agp-9-2-1-kotlin-build-errors-i-hit-and-how-i-fixed-them-1565bb36b96f
- author_url
- https://medium.com/@navczydev
- status
- ok
- fetched_at
- 2026-06-09 15:37:30