# Migrating to AGP 9.2.1: Kotlin build errors I hit and how I fixed them

DevFeed: [Migrating to AGP 9.2.1: Kotlin build errors I hit and how I fixed them](<https://devfeed.tech/articles/migrating-to-agp-9-2-1-kotlin-build-errors-i-hit-and-how-i-fixed-them-25977.md>)

Original publisher: [Read original article](<https://navczydev.medium.com/migrating-to-agp-9-2-1-kotlin-build-errors-i-hit-and-how-i-fixed-them-1565bb36b96f?source=rss-711ab22c5c77------2>)

Author: Nav Singh

Published: 2026-05-27T01:03:56Z

Content type: tutorial

Language: en

Sources: [Stories by Nav Singh 🇨🇦 on Medium](<https://devfeed.tech/sources/stories-by-nav-singh-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [migration](<https://devfeed.tech/topics/migration.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [developer tooling](<https://devfeed.tech/topics/developer-tooling.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-gradle-plugin](<https://devfeed.tech/tags/android-gradle-plugin.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [dagger-hilt](<https://devfeed.tech/tags/dagger-hilt.md>), [errors](<https://devfeed.tech/tags/errors.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [ksp](<https://devfeed.tech/tags/ksp.md>), [migration](<https://devfeed.tech/tags/migration.md>)

## AI overview

A tutorial documenting a small Android project migration to AGP 9.2.1. It explains build errors caused by AGP 9's built-in Kotlin support and shows fixes involving removal of the old Kotlin Android plugin, migration from KAPT to KSP for Hilt, and replacement of the legacy kotlinOptions DSL.

## Source excerpt

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, and kotlinOptions no longer work the same way. Error 1: Cannot add extension with name kotlinCannot 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.Fixplugins { 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 the KSP 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 setti