Community程式設計與開發github.com

lerchenflo/claudeskills

將 Android 專案升級或遷移至 Android Gradle Plugin (AGP) 9 版本。請勿使用此技能遷移 Kotlin Multiplatform (KMP) 專案。

claudeskills 是什麼?

此技能專為使用 Android Gradle Plugin (AGP) 9 的大型遷移任務而設計,適用於需要將 Android 專案從 AGP 8 升級至 AGP 9 的開發者。它提供逐步指南,涵蓋相依性更新、內建 Kotlin 遷移、新的 AGP DSL、從 kapt 遷移至 KSP 或 legacy-kapt、BuildConfig 調整以及 gradle.properties 清理。技能支援 Claude Code,但明確排除 Kotlin Multiplatform (KMP) 專案,因為 AGP 9 不支援 KMP。在開始遷移前,技能會檢查目前 AGP 版本,若低於 9 則要求使用 Android Studio 的 AGP Upgrade Assistant 更新至最新穩定版,或在使用者跳過此要求時直接升級。選用的參考文件包括 AGP 9 發布說明、內建 Kotlin 遷移指南、gradle 配方與疑難排解,並強調避免使用 Python 腳本及不必要的清理任務。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lerchenflo/claudeskills/tree/HEAD/android/agp-9-upgrade

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

遷移指南

請參閱 AGP 9 遷移指南 了解從 AGP 8 升級到 AGP 9 的重大變更,其中許多是破壞性變更。

需求

如果使用者要求更新或遷移至 AGP 9,請先檢查專案中使用的 AGP 版本。若低於 9,請停止並要求使用者在 Android Studio 中執行 AGP Upgrade Assistant 更新至最新穩定版的 AGP,並在完成後確認。使用者也可以要求跳過此需求;若如此,您應在 AGP 9 遷移過程中將 AGP 版本更新至最新穩定版。請參閱 AGP 9 遷移指南 了解如何執行。

每個 AGP 版本都有其與其他工具(如 Gradle、JDK 和 Kotlin)的相容性組合。每個版本的發布說明都將包含一個 相容性 表格,說明這些工具的最低版本。

請勿將此技能用於 KMP 專案,因為它們不受支援。

步驟

如果 AGP 已達到 9 或更高版本,請執行以下操作:

第 1 步:更新相依性

如果專案中使用 KSP(com.google.devtools.ksp),請確保其版本為 2.3.6 或更高。

如果專案中使用 Hilt,請確保其版本為 2.59.2 或更高。

第 2 步:遷移至內建 Kotlin

請參閱 指南 瞭解詳細資訊。

第 3 步:遷移至新的 AGP DSL

請參閱 指南 瞭解詳細資訊。

另請參閱 gradle-recipes 了解如何將舊程式碼遷移至與 AGP 9 和新 DSL 相容的程式碼的範例。

第 4 步:將 kapt 遷移至 KSP 或 legacy-kapt

如果專案中使用 KSP(com.google.devtools.ksp)或 kapt(org.jetbrains.kotlin.kapt),請參閱 KSP、kapt 和 legacy-kapt 瞭解詳細遷移步驟。

第 5 步:BuildConfig

如果任何 Android 模組包含自訂的 BuildConfig 欄位,請參閱 BuildConfig 瞭解詳細資訊。

第 6 步:更新 gradle.properties

遷移完成後,請檢查 gradle.properties。移除以下標誌:

  1. android.builtInKotlin
  2. android.newDsl
  3. android.uniquePackageNames
  4. android.enableAppCompileTimeRClass

此外,刪除所有您建立的暫存檔案。

指導原則

  • 切勿編寫或執行 Python 腳本。
  • 僅在檢查外部相依性時搜尋 Gradle 快取,且僅作為最後手段。
  • 切勿在 gradle.properties 中加入 android.disallowKotlinSourceSets=false。
  • 驗證變更時,請勿執行 clean 任務。這是在浪費時間。

驗證

遷移完成後,請驗證以下事項:

  1. Gradle IDE 同步成功。
  2. ./gradlew help 成功。
  3. ./gradlew build --dry-run 成功。

疑難排解

Paparazzi v2.0.0-alpha04 及更低版本在 AGP 9 中存在問題。請參閱 references/paparazzi-gradle-9.md 瞭解詳細資訊。

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

lerchenflo/claudeskills

Provides instructions for installing and using the `android` CLI. The `android` command-line tool is a critical tool for Android development and helps you create new Android projects, run Android apps on devices, manage and interact with Android virtual devices (including screenshots and UI inspection), manage Android SDK components, look up official Android documentation, and discover and install official Android skills.

lerchenflo/claudeskills

Manages Android performance profiling and debugging. Triggers when the user asks to record or analyze Android performance data, such as system traces, heap dumps, method recordings, callstack samples, memory allocations, or investigate bottlenecks, jank, memory leaks, and app startup issues on Android, or when the user asks to write, debug, or execute ad-hoc SQL queries. Applies to both user and system apps or services.

lerchenflo/claudeskills

Analyzes Android apps to identify key user workflows for AppFunctions such as creating a note, playing media, or sending an automated or AI agent triggered message, voice commands, or system shortcuts, without needing to open the app UI. Generates Kotlin code to expose these workflows to the Android system, allowing agents to discover and execute them on-device. Also refines KDoc documentation to ensure AI agents correctly understand and use the provided functionality.

lerchenflo/claudeskills

Use this skill to migrate your Jetpack Compose app to add adaptive edge-to-edge support and troubleshoot common issues. Use this skill to fix UI components (like buttons or lists) that are obscured by or overlapping with the navigation bar or status bar, fix IME insets, and fix system bar legibility.

相關技能