Agp 9 Upgrade
Android (Google)OfficialCreated by Google LLCDistributed by Android (Google)
- Skill
- Workflow
- Software development
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured workflow to upgrade Android projects to AGP 9. It handles the transition to built-in Kotlin support, updates dependencies like KSP and Hilt, migrates to the new AGP DSL, and cleans up obsolete properties in gradle.properties. It is designed for standard Android projects and explicitly excludes Kotlin Multiplatform (KMP) projects.
What it does
- Updates project dependencies including KSP and Hilt to compatible versions.
- Facilitates the migration to AGP 9 built-in Kotlin support.
- Guides the transition to the new AGP DSL interfaces.
- Assists in migrating from kapt to KSP or legacy-kapt.
- Cleans up deprecated flags in gradle.properties.
- Verifies the migration through Gradle sync and build checks.
When to use it
- When you need to upgrade an existing Android project to AGP 9.
- When you are ready to adopt built-in Kotlin support in your Android modules.
- When your project requires migration to the new AGP 9 DSL interfaces.
- When you need to update build dependencies to ensure compatibility with AGP 9.
Advantages
- Simplifies complex build system migrations through a guided, step-by-step process.
- Ensures project compatibility with the latest Android build tools and JDK requirements.
- Reduces build configuration overhead by leveraging built-in Kotlin support.
- Provides clear verification steps to ensure the project remains in a buildable state.
Usage examples
- “Migrate my Android project to AGP 9.”
- The agent will check your current AGP version, guide you through dependency updates, DSL changes, and built-in Kotlin migration, and verify the build.
- “Help me update my app to use AGP 9 and the new DSL.”
- The agent will initiate the migration workflow, ensuring your build files are updated to the new DSL interfaces and removing obsolete properties.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/android/agp-9-upgrade/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip agp-9-upgrade.zip -d .agents/skills
Documentation by Google LLC
Migration guide
See the AGP 9 migration guide for the major changes, many breaking, in AGP 9 compared to AGP 8.
Requirements
If the user requests to update or migrate to AGP 9, first check the AGP version used in the project. If it is lower than 9, stop and ask the user to run the AGP Upgrade Assistant in Android Studio to update to the latest stable version of AGP, and confirm when done. The user may also request that this requirement be skipped; if this is the case, you should update the version of AGP to the latest stable version as part of the AGP 9 migration. See the AGP 9 migration guide for how to do this.
Each version of AGP has its own set of compatibilities with other tools, such as Gradle, JDK, and Kotlin. The release notes for each of these versions will include a Compatibility table indicating the minimum versions for these tools.
Do not use this skill for KMP projects, as they are unsupported.
Steps
If AGP is already at 9 or higher, then do the following:
Step 1: Update dependencies
If KSP (com.google.devtools.ksp) is used in the project, ensure it is on
version 2.3.6 or higher.
If Hilt is used in the project, ensure it is on version 2.59.2 or higher.
Step 2: Migrate to built-in Kotlin
See the guide for detailed information.
Step 3. Migrate to the new AGP DSL
See the guide for detailed information.
See also gradle-recipes for examples on how to migrate old code to code that is compatible with AGP 9 and the new DSL.
Step 4. Migrate kapt to KSP or legacy-kapt
If KSP (com.google.devtools.ksp) or kapt (org.jetbrains.kotlin.kapt) are
used in the project, see KSP, kapt, and legacy-kapt for detailed migration
steps.
Step 5. BuildConfig
If any Android module contains custom BuildConfig fields, see BuildConfig for detailed information.
Step 6. Update gradle.properties
After the migration, check gradle.properties. Remove the following flags:
android.builtInKotlin
android.newDsl
android.uniquePackageNames
android.enableAppCompileTimeRClass
Additionally, delete all temporary files you've created.
Guidelines
Never write or run python scripts.
Only search the Gradle dependency cache when inspecting external dependencies, and only as a last resort.
Never add
android.disallowKotlinSourceSets=falsetogradle.properties.When verifying changes, don't run the
cleantask. This is a waste of time.
Verification
After migration, verify the following:
Gradle IDE sync succeeds.
./gradlew helpsucceeds../gradlew build --dry-runsucceeds.
Troubleshooting
Paparazzi v2.0.0-alpha04 and lower versions have issues with AGP 9. See references/paparazzi-gradle-9.md for details.
Files
- ATTRIBUTION.mdAdded by AutoGineer970 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md3.4 KiB
- references/android/build/migrate-to-built-in-kotlin.md13.1 KiB
- references/android/build/releases/agp-9-0-0-release-notes.md51.3 KiB
- references/buildconfig.md1.5 KiB
- references/ksp-kapt.md1.7 KiB
- references/paparazzi-gradle-9.md1.1 KiB
- references/recipes.md2.2 KiB
references/android/build/migrate-to-built-in-kotlin.md
Android Gradle plugin 9.0 introduces built-in Kotlin support and enables it
by default. That means you no longer have to apply the
org.jetbrains.kotlin.android (or kotlin-android) plugin in your build files
to compile Kotlin source files.
With built-in Kotlin, your build files are simpler and you can avoid
compatibility issues between AGP and the kotlin-android plugin.
[!NOTE] Note: Built-in Kotlin replaces the
kotlin-androidplugin only. If you are writing a Kotlin Multiplatform (KMP) library module, you still need to apply theorg.jetbrains.kotlin.multiplatformplugin and thecom.android.kotlin.multiplatform.libraryplugin. Also, using theorg.jetbrains.kotlin.multiplatformplugin together with thecom.android.libraryorcom.android.applicationplugin is no longer allowed when built-in Kotlin is enabled.
Enable built-in Kotlin
You need AGP 9.0 or higher to have built-in Kotlin support.
AGP 9.0 already enables built-in Kotlin for all your modules where you apply
AGP, so you don't need to do anything to enable it. However, if you previously
opted out of built-in Kotlin by setting android.builtInKotlin=false
in the gradle.properties file, you need to remove that setting or set it to
true.
[!NOTE] Note: You can also enable built-in Kotlin for one module at a time.
Built-in Kotlin requires some changes to your project, so after you have built-in Kotlin enabled, follow the next steps to migrate your project.
Migration steps
After you upgrade your project from an older AGP version to AGP 9.0 or after you manually enable built-in Kotlin, you might see the following error message:
Failed to apply plugin 'org.jetbrains.kotlin.android'.
> Cannot add extension with name 'kotlin', as there is an extension already registered with that name....or
Failed to apply plugin 'com.jetbrains.kotlin.android'
> The 'org.jetbrains.kotlin.android' plugin is no longer required for Kotlin support since AGP 9.0.This error occurs because built-in Kotlin requires some changes to your project. To resolve this error, follow these steps:
[!NOTE] Note: If you're not yet ready to migrate your project, you can also opt out of built-in Kotlin.
1. Remove the kotlin-android plugin
Remove the org.jetbrains.kotlin.android (or kotlin-android) plugin from
the module-level build files where you apply it.
The exact code to remove depends on
whether you use version catalogs to declare plugins.
With version catalogs
Kotlin
// Module-level build file
plugins {
alias(libs.plugins.kotlin.android)
}Groovy
// Module-level build file
plugins {
alias(libs.plugins.kotlin.android)
}No version catalogs
Kotlin
// Module-level build file
plugins {
id("org.jetbrains.kotlin.android")
}Groovy
// Module-level build file
plugins {
id 'org.jetbrains.kotlin.android'
}Then, remove the plugin from your top-level build file:
With version catalogs
Kotlin
// Top-level build file
plugins {
alias(libs.plugins.kotlin.android) apply false
}Groovy
// Top-level build file
plugins {
alias(libs.plugins.kotlin.android) apply false
}No version catalogs
Kotlin
// Top-level build file
plugins {
id("org.jetbrains.kotlin.android") version "KOTLIN_VERSION" apply false
}Groovy
// Top-level build file
plugins {
id 'org.jetbrains.kotlin.android' version 'KOTLIN_VERSION' apply false
}If you use version catalogs, also remove the plugin definition from the
version catalog TOML file (usually gradle/libs.versions.toml):
[plugins]
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "KOTLIN_VERSION" }2. Migrate the kotlin-kapt plugin if necessary
The org.jetbrains.kotlin.kapt (or kotlin-kapt) plugin is incompatible with
built-in Kotlin. If you use kapt, we recommend that you
migrate your project to KSP.
If you can't migrate to KSP yet, replace the kotlin-kapt plugin with the
com.android.legacy-kapt plugin, using the same version as your Android Gradle
plugin.
For example, with version catalogs, update your version catalog TOML file as follows:
[plugins]
android-application = { id = "com.android.application", version.ref = "AGP_VERSION" }
# Add the following plugin definition
legacy-kapt = { id = "com.android.legacy-kapt", version.ref = "AGP_VERSION" }
# Remove the following plugin definition
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "KOTLIN_VERSION" }Then, update your build files:
Kotlin
// Top-level build file
plugins {
alias(libs.plugins.legacy.kapt) apply false
alias(libs.plugins.kotlin.kapt) apply false
}Groovy
// Top-level build file
plugins {
alias(libs.plugins.legacy.kapt) apply false
alias(libs.plugins.kotlin.kapt) apply false
}Kotlin
// Module-level build file
plugins {
alias(libs.plugins.legacy.kapt)
alias(libs.plugins.kotlin.kapt)
}Groovy
// Module-level build file
plugins {
alias(libs.plugins.legacy.kapt)
alias(libs.plugins.kotlin.kapt)
}[!NOTE] Note: If you declare the
kotlin-kaptplugin in theplugins{}block askotlin("kapt") version "<KOTLIN_VERSION>", then remove that line instead.
3. Migrate the android.kotlinOptions{} DSL if necessary
If you use the android.kotlinOptions{} DSL, you need to
migrate it to the kotlin.compilerOptions{} DSL.
For example, update this code:
Kotlin
android {
kotlinOptions {
languageVersion = "2.0"
jvmTarget = "11"
}
}Groovy
android {
kotlinOptions {
languageVersion = "2.0"
jvmTarget = "11"
}
}...to the new DSL:
Kotlin
kotlin {
compilerOptions {
languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
// Optional: Set jvmTarget
// jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
}
}Groovy
kotlin {
compilerOptions {
languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
// Optional: Set jvmTarget
// jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
}
}[!NOTE] Note: With built-in Kotlin, you don't need to set
kotlin.compilerOptions.jvmTargetbecause its value defaults toandroid.compileOptions.targetCompatibility.
4. Migrate the kotlin.sourceSets{} DSL if necessary
When you use the kotlin-android plugin, AGP lets you add additional Kotlin
source directories using either the android.sourceSets{} DSL or the
kotlin.sourceSets{} DSL.
With the android.sourceSets{} DSL, you can add the directories to either the
AndroidSourceSet.kotlin set or the AndroidSourceSet.java set.
With built-in Kotlin, the only supported option is to add the directories to the
AndroidSourceSet.kotlin set using the android.sourceSets{} DSL.
If you use unsupported options, migrate them as follows:
Kotlin
# Adding Kotlin source directories to kotlin.sourceSets is not supported
kotlin.sourceSets.named("main") {
kotlin.srcDir("additionalSourceDirectory/kotlin")
}
# Adding Kotlin source directories to AndroidSourceSet.java is also not supported
android.sourceSets.named("main") {
java.directories += "additionalSourceDirectory/kotlin"
}
# Add Kotlin source directories to AndroidSourceSet.kotlin
android.sourceSets.named("main") {
kotlin.directories += "additionalSourceDirectory/kotlin"
}Groovy
# Adding Kotlin source directories to kotlin.sourceSets is not supported
kotlin.sourceSets.named("main") {
kotlin.srcDir("additionalSourceDirectory/kotlin")
}
# Adding Kotlin source directories to AndroidSourceSet.java is also not supported
android.sourceSets.named("main") {
java.directories.add("additionalSourceDirectory/kotlin")
}
# Add Kotlin source directories to AndroidSourceSet.kotlin
android.sourceSets.named("main") {
kotlin.directories.add("additionalSourceDirectory/kotlin")
}If you want to add a Kotlin source directory to a specific variant or if the
directory is generated by a task, you can use the
addStaticSourceDirectory or addGeneratedSourceDirectory methods
in the variant API:
Kotlin
androidComponents.onVariants { variant ->
variant.sources.kotlin!!.addStaticSourceDirectory("additionalSourceDirectory/kotlin")
variant.sources.kotlin!!.addGeneratedSourceDirectory(TASK_PROVIDER, TASK_OUTPUT)
}Groovy
androidComponents.onVariants { variant ->
variant.sources.kotlin!!.addStaticSourceDirectory("additionalSourceDirectory/kotlin")
variant.sources.kotlin!!.addGeneratedSourceDirectory(TASK_PROVIDER, TASK_OUTPUT)
}Report issues
If you encounter issues after completing the previous steps, review the known issues in issue #438678642 and give us feedback if needed.
Opt out of built-in Kotlin
If you are unable to migrate your project to use built-in Kotlin, set
android.builtInKotlin=false in the gradle.properties file to temporarily
disable it.
When you do that, the build shows a warning reminding you to migrate to built-in
Kotlin as you won't be able to disable built-in Kotlin in AGP 10.0.
[!NOTE] Note: You also need to set
android.newDsl=falseto opt out of the new DSL because thekotlin-androidplugin is not compatible with it.
Once you're ready to migrate your project, enable built-in Kotlin and follow the migration steps.
Module-by-module migration
The android.builtInKotlin Gradle property lets you enable or disable built-in
Kotlin for all your modules where you apply AGP.
If migrating all your modules at once is challenging, you can migrate one module at a time:
Set
android.builtInKotlin=falsein thegradle.propertiesfile to disable built-in Kotlin for all modules.Apply the
com.android.built-in-kotlinplugin to the module you want to enable built-in Kotlin, using the same version as your Android Gradle plugin.Follow the previous migration steps to migrate this module to built-in Kotlin.
Once you've migrated all your modules, remove the
android.builtInKotlin=falsesetting ingradle.propertiesand thecom.android.built-in-kotlinplugin in your build files.
Option to selectively disable built-in Kotlin
Android Gradle plugin 9.0 enables built-in Kotlin for all modules where it is applied. We recommend disabling built-in Kotlin selectively for modules that don't have Kotlin sources in large projects. This removes both the Kotlin compilation task, which has a small build performance cost, and the automatic dependency on the Kotlin standard library.
To disable built-in Kotlin for a module,
set enableKotlin = false in that module's build file:
Kotlin
android {
enableKotlin = false
}Groovy
android {
enableKotlin = false
}Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Google LLC
- Publisher
- Android (Google) (Official)
- Distributed by
- Android (Google)
- Source
- android/skills · build-system/agp/agp-9-upgrade · commit bf68e2d
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.txt)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google LLC or Android (Google).
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download agp-9-upgrade.zip