跳到正文
Skillpedia
移动应用10k · #11907

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/android/skills/blob/main/build-system/agp/agp-9-upgrade/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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:

  1. android.builtInKotlin
  2. android.newDsl
  3. android.uniquePackageNames
  4. 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=false to gradle.properties.
  • When verifying changes, don't run the clean task. This is a waste of time.

Verification

After migration, verify the following:

  1. Gradle IDE sync succeeds.
  2. ./gradlew help succeeds.
  3. ./gradlew build --dry-run succeeds.

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能