agp-9-upgrade
它能做什么
这个技能把 Android 项目迁移到 Android Gradle Plugin 9 版本,并更新需要配套升级的依赖。适合正在进行该升级的 Android 开发者。它不涵盖 Kotlin Multiplatform 项目。
适用场景
- ✓当你的 Android 项目仍在使用旧版 Android Gradle Plugin,并想迁移到 9 版本时。
- ✓当 Android Gradle Plugin 9 升级导致构建失败、你需要迁移步骤的时候。
- ✓当你希望把 KSP 或 Hilt 更新到能与 Android Gradle Plugin 9 配合使用的版本的时候。
技能链接
https://github.com/android/skills/blob/main/build-system/agp/agp-9-upgrade/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把我的 Android 项目升级到 Android Gradle Plugin 9,并修复升级后出现的问题。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能首先检查当前插件版本。如果低于 9,除非你要求跳过此步骤,否则它会请你在 Android Studio 中运行升级助手。然后它会按照迁移指南进行操作。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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.
常见问题
我需要先运行升级助手吗?
如果项目版本低于 9,该技能会请你运行它,除非你要求跳过这一步。
这适用于 Kotlin Multiplatform 项目吗?
不适用。此技能不支持这些项目。
还有哪些工具需要更新?
一些工具,例如 KSP 和 Hilt,需要满足最低版本要求,该技能会为它们更新。
详情
作者的原始描述
Upgrades, or migrates, an Android project to use Android Gradle Plugin (AGP) version 9. Do not use this skill for migrating Kotlin Multiplatform (KMP) projects.
repo: android/skills
热度
- GitHub 星标
- 10k
- 排名
- #11907
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/29
评论
- …
同一仓库的更多技能
camerax
10k帮你的智能体使用 CameraX 构建 Android 相机功能,包括视频录制、硬件控制以及 ML Kit 和 Media3 效果。
android-for-cars-parked-apps
10k帮你的智能体把 Android 视频、游戏或浏览器应用调整为可在 Android Auto 和 Android Automotive 上以停放应用形式运行。
appfunctions
10k帮你的智能体在 Android 应用中找到关键工作流,并把它们暴露为 AI 智能体和语音命令可以运行的 AppFunctions。
litert-lm
10k帮你的智能体构建一个在设备上运行开放文本 AI 模型的 Android 应用,使用 LiteRT-LM Kotlin API。