For developers · Checked 1 October 2026

Migrating to Android Gradle plugin 9

Short answer: AGP 9 turns on built-in Kotlin and the new DSL by default. To migrate, remove the org.jetbrains.kotlin.android plugin, replace kotlin-kapt with KSP or com.android.legacy-kapt, move android.kotlinOptions to kotlin.compilerOptions, add extra Kotlin sources through android.sourceSets, and replace applicationVariants with the androidComponents API. Start with the AGP Upgrade Assistant in Android Studio. If a plugin blocks you, android.builtInKotlin=false and android.newDsl=false buy time, but Google says that opt-out goes away in AGP 10. The current release is AGP 9.4 (September 2026).

Defaults that changed in AGP 9.0

From Google’s AGP 9.0 release notes. Each can be set back in gradle.properties while you migrate.

Gradle propertyAGP 8.13 → 9.0What it means
android.builtInKotlinfalse → trueKotlin compiles without the kotlin-android plugin
android.newDslfalse → trueOnly the public DSL interfaces; the legacy variant API is gone
android.uniquePackageNamesfalse → trueEvery library needs a distinct package name
android.useAndroidxfalse → trueAndroidX dependencies by default
android.sdk.defaultTargetSdkToCompileSdkIfUnsetfalse → truetargetSdk defaults to compileSdk, not minSdk
android.enableAppCompileTimeRClassfalse → trueApps compile against a non-final R class
android.r8.strictFullModeForKeepRulesfalse → true-keep class A no longer keeps its default constructor
android.proguard.failOnMissingFilesfalse → trueA missing keep file fails the build
android.defaults.buildfeatures.resvaluestrue → falseTurn resValues on only where needed

Requirements

AGP 9.0 needs Gradle 9.1.0, SDK Build Tools 36.0.0 and JDK 17; AGP 9.4 needs Gradle 9.6.0 and supports up to API level 37. AGP 9 has a runtime dependency on the Kotlin Gradle plugin 2.2.10: a lower KGP is upgraded to 2.2.10 automatically, and KSP below 2.2.10-2.0.2 is upgraded to match. To use a newer KGP or KSP, declare it in the top-level buildscript classpath. Downgrading KGP is possible only with built-in Kotlin turned off. Android Studio has two agent skills for the upgrade: the AGP 9 upgrade skill for regular apps, bundled in Android Studio, see Android skills in Android Studio, and a JetBrains skill for KMP apps.

Built-in Kotlin, step by step

After the upgrade you may see Cannot add extension with name 'kotlin', as there is an extension already registered with that name or The 'org.jetbrains.kotlin.android' plugin is no longer required for Kotlin support since AGP 9.0. Google’s fix has four steps. 1. Remove org.jetbrains.kotlin.android from module and top-level build files and from libs.versions.toml. 2. kapt is incompatible with built-in Kotlin: migrate to KSP, or replace org.jetbrains.kotlin.kapt with com.android.legacy-kapt at your AGP version. 3. Move android { kotlinOptions { } } to kotlin { compilerOptions { } }; jvmTarget now defaults to compileOptions.targetCompatibility. 4. Extra Kotlin source folders go only in android.sourceSets under kotlin.directories; adding them through kotlin.sourceSets or the java set is what triggers «Using kotlin.sourceSets DSL to add Kotlin sources is not allowed with built-in Kotlin». For generated sources, use variant.sources.kotlin with addStaticSourceDirectory or addGeneratedSourceDirectory.

The new DSL and variant API

AGP 9 uses only the new public DSL interfaces, so BaseExtension and the old variant API are gone. Replace applicationVariants, libraryVariants and the test variants with androidComponents.onVariants, variantFilter with androidComponents.beforeVariants, and sdkDirectory or adbExecutable with androidComponents.sdkComponents. A ClassCastException saying ApplicationExtensionImpl cannot be cast to BaseExtension means your build logic or a third-party plugin still uses the old types: update the plugin to a version that supports AGP 9. To unblock yourself meanwhile, android.newDsl=false brings the old types back for the whole project, and AGP 9.4 adds android.newDsl.optOut=:module for single modules.

Kotlin Multiplatform projects

With AGP 9, the org.jetbrains.kotlin.multiplatform plugin is no longer compatible with com.android.application or com.android.library in the same module. JetBrains’ migration has two parts: move the Android entry point, such as MainActivity, into a separate androidApp module, then switch the shared module to the Android-KMP library plugin, com.android.kotlin.multiplatform.library. Keep expect and actual declarations in the shared module. As a short-term workaround JetBrains documents android.enableLegacyVariantApi=true. For iOS UI in the same projects, see Compose Multiplatform and Liquid Glass.

Flutter projects

Flutter’s docs say apps that apply the Kotlin Gradle plugin fail to build on AGP 9 without migration. Flutter 3.44 added temporary support for the legacy plugin with android.builtInKotlin=false, and Flutter 3.47 supports android.builtInKotlin=true once an app and all its plugins have migrated. Flutter keeps the AGP DSL compatible with the legacy types for now and plans to remove support for applying KGP later. Projects that don’t apply KGP today shouldn’t migrate to built-in Kotlin. The iOS side of the same release cycle is in the iOS 27 UIScene requirement.

Where Censuus fits

A clean build keeps releases on schedule; being found brings people to them. Censuus ranks apps by the visits they draw, and adding your app is free through the List my app form. Placement comes from traffic and sponsorship: apps climb on the visits they draw, and a sponsor can pay to rise higher. For the Play side of builds, see 16 KB page size support.

Frequently asked questions

Do I still need the kotlin-android plugin with AGP 9?

No. AGP 9 compiles Kotlin with built-in Kotlin, and applying org.jetbrains.kotlin.android causes a build error. Remove it from your build files and version catalog.

Does kapt work with AGP 9?

Not the kotlin-kapt plugin. Google recommends migrating to KSP; if you can’t yet, use com.android.legacy-kapt with the same version as AGP.

How do I fix «kotlin.sourceSets DSL to add Kotlin sources is not allowed with built-in Kotlin»?

Move the folder to android.sourceSets, adding it to kotlin.directories, or register it per variant with variant.sources.kotlin.addStaticSourceDirectory.

How do I opt out of built-in Kotlin?

Set android.builtInKotlin=false and android.newDsl=false in gradle.properties. You can then enable built-in Kotlin module by module with the com.android.built-in-kotlin plugin. Google says the opt-out won’t be possible in AGP 10.

When is AGP 10 released?

Google hasn’t published a date. JetBrains’ KMP guide says it is likely in the second half of 2026; as of 1 October 2026 the latest release is AGP 9.4.

How do I migrate a KMP project to AGP 9?

Move the Android app entry point into its own module and switch the shared module to the com.android.kotlin.multiplatform.library plugin, following JetBrains’ AGP 9 migration guide.

Guides for app developers

Put your app in the ranking

Censuus ranks apps by the visits they draw and by sponsorship, no bots. Listing is free; sponsorship raises placement.