play-billing-library-version-upgrade
它能做什么
这个技能把 Android 项目的 Google Play Billing Library 升级或迁移到最新的稳定版本。它会找出真实的起始版本,包括已弃用的代码,并规划相关步骤。适合维护应用内购买代码的 Android 开发者。
适用场景
- ✓当你的 Android 应用使用旧版 Google Play Billing Library,并且你想更新它的时候。
- ✓当你的应用因使用了 SkuDetails 等已弃用的计费代码而构建失败时。
- ✓当你需要一份分步计划,以跨越多个主要计费库版本的时候。
技能链接
https://github.com/android/skills/blob/main/play/play-billing-library-version-upgrade/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把我 Android 应用中的 Google Play Billing Library 升级到最新的稳定版本。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能会检查计费依赖的版本,然后尝试构建。如果构建失败,它会扫描已弃用的计费类,以找出真实版本。然后它会规划直接迁移或分步迁移到最新稳定版本的方案。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Phase 0: Intent Message
Reporting Action: Before proceeding, immediately tell the user: "I will upgrade Play Billing Library to the latest version."
Phase 1: Discovery & Situational Awareness
- Primary Check (Build Version) : Locate the project's billing dependency (e.g.,
com.android.billingclient:billing) inbuild.gradle,build.gradle.kts, orlibs.versions.toml. - Initial Compilation Test: Attempt to sync and build the project immediately.
- Fallback Discovery (Effective Version) :
- Trigger: Only if the build fails immediately, scan the source code for deprecated artifacts.
- Logic : The presence of deprecated APIs indicates the "Effective Version" ---defined as the version where those specific APIs were last available, not when they were introduced.
- Example : If
SkuDetailsis present, treat the baseline as PBL v7 or earlier (regardless of the version string inbuild.gradle).
- Identify Target & Path : Access the version tool or release notes to find the latest stable version and calculate a [Direct/Stepped] migration path based on the Effective Version baseline.
- Calculate Migration Path :
- If the Effective Version is within 2 major versions of the target: Plan a Direct Migration.
- If it is more than 2 major versions behind: Plan a Stepped Migration. Migrate by two major versions at a time (e.g., v4 -> v6 -> v8) until you are within two versions of the target.
- Reporting Action: Before proceeding, tell the user: "I've detected you are effectively on PBL [Current] and the latest is [Target]. I am planning a [direct/stepped] migration path."
Phase 2: Contextual Document Mapping & Planning
For every major version jump identified in your path, you MUST synthesize instructions from:
- Migration Guide (where
[X]is the target major version). - Release Highlights : The "Deprecations" and "Breaking Changes" sections of the relevant Release Notes.
- Developer Documentation: Consult your knowledge of the Google Play Billing documentation regarding the relevant features used in this app (e.g., Subscriptions, One-Time Products).
- Develop the Plan: Identify every specific code change required (API removals, class replacements, logic shifts) and print this out as a checklist.
Phase 3: Instructions for Execution
Reporting Action: For each of the following steps, give a brief explanation of what you will be doing prior to execution, and a brief summary of what you accomplished afterwards.
Step 1: SDK & Environment Alignment
- Action : Update
build.gradleto meet SDK requirements (e.g., "PBL 9 requirescompileSdk35"). - Gradle Version: Verify if the new library requires a newer Android Gradle Plugin (AGP) or Kotlin version.
Step 2: Intent-based Refactoring
Analyze the intent of the existing code rather than performing purely textual string replacement.
- Action : You MUST follow all deprecation instructions and refactor patterns from both the references/migration-logic.md section, the official migration guides, and the general documentation pages identified in Phase 2.
- Verification : Verify you are doing all steps from all documentation and then making sure you follow the specific directions from the checklist in the references.
Step 3: Sequential Verification (Only applicable for Stepped Migrations)
- Upgrade to the first major intermediate version in your path.
- Run
./gradlew assembleDebugto verify no intermediate breaking changes were missed. - Repeat until you reach the final target version.
Step 4: Final Validation Checklist
- Smart Checklist Verification:
- Open references/version-checklist.md and locate the Smart Version-Specific Checklist.
- Action: For every version between your [Detected Effective Version] and [Detected New Version], verify that every item has been addressed in the code using "Find in Files" or structural analysis.
- Tests : Run all unit and implementation tests (
./gradlew test). - Clean Build : Verify the project completes a full clean build:
./gradlew clean assembleDebug. Then, run./gradlew syncand./gradlew builds
常见问题
为什么构建文件中的版本号并不总是一致?
已弃用的代码可能表明应用实际上使用的是较旧的版本,因此该技能会使用该代码最后可用的版本。
什么时候会使用分步迁移?
当应用落后于最新稳定版本超过两个主要版本时,该技能会规划分步升级。
它会测试我的购买流程吗?
该技能专注于升级和构建步骤,因此你仍应自行测试购买功能。
详情
作者的原始描述
Use this skill when upgrading or migrating an Android project from any legacy Google Play Billing Library (PBL) version to the latest stable version of PBL.
repo: android/skills
热度
- GitHub 星标
- 10k
- 排名
- #11929
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/29
评论
- …
同一仓库的更多技能
agp-9-upgrade
10k帮你的智能体把 Android 应用升级到 Android Gradle Plugin 9,并处理其中的破坏性变更。不适用于多平台项目。
camerax
10k帮你的智能体使用 CameraX 构建 Android 相机功能,包括视频录制、硬件控制以及 ML Kit 和 Media3 效果。
android-for-cars-parked-apps
10k帮你的智能体把 Android 视频、游戏或浏览器应用调整为可在 Android Auto 和 Android Automotive 上以停放应用形式运行。
appfunctions
10k帮你的智能体在 Android 应用中找到关键工作流,并把它们暴露为 AI 智能体和语音命令可以运行的 AppFunctions。