rc-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRevenueCat Android Setup
RevenueCat Android 配置指南
Configure a RevenueCat project so the Android SDK can fetch offerings, validate purchases, and grant entitlements. This skill covers the dashboard side of setup and the service account connection to Google Play.
The scope stops at "dashboard ready, API key in hand." SDK initialization code belongs to the rc-configuring-the-sdk skill.
配置RevenueCat项目,使Android SDK能够获取产品套餐(Offerings)、验证购买并授予权益(Entitlements)。此技能涵盖控制台端的设置流程,以及与Google Play的服务账户连接步骤。
本技能的范围截止到“控制台配置完成、获取到API密钥”。SDK初始化代码属于 rc-configuring-the-sdk 技能的内容。
Phase 1: Discovery
阶段1:准备检查
Confirm these items before you touch the RevenueCat dashboard. Missing any of them will block the connection step.
| Prerequisite | Where it lives | Why RevenueCat needs it |
|---|---|---|
| Google Play Console app | Play Console | Dashboard connects by package name |
| Package name | Play Console app listing | Must match your Android app exactly |
| In-app products or subscriptions | Play Console monetization | RevenueCat imports the catalog |
| Base plans for subscriptions | Play Console subscription | Billing Library 6+ requires them |
| Google Cloud service account JSON | Google Cloud Console | RevenueCat authenticates to the Play Developer API |
| Financial data viewer permission | Play Console users and permissions | Service account reads subscription state |
Ask the user:
- Is the app already published on Play (even as internal testing)?
- Are products live in Play Console, or still drafts?
- Do you have the service account JSON, or do you need the creation steps?
If products do not exist yet, pause. Product creation is a Play Console task outside this skill.
在操作RevenueCat控制台前,请确认以下事项。缺少任何一项都会阻碍后续的连接步骤。
| 前置条件 | 获取位置 | RevenueCat需要它的原因 |
|---|---|---|
| Google Play Console应用 | Play Console | 控制台通过包名建立连接 |
| 包名 | Play Console应用列表 | 必须与您的Android应用完全匹配 |
| 应用内产品或订阅 | Play Console变现模块 | RevenueCat会导入产品目录 |
| 订阅基础方案 | Play Console订阅模块 | Billing Library 6+版本要求必须配置 |
| Google Cloud服务账户JSON文件 | Google Cloud Console | RevenueCat通过它验证Play Developer API的身份 |
| 财务数据查看权限 | Play Console用户与权限模块 | 服务账户需要读取订阅状态 |
请询问用户:
- 应用是否已在Play发布(即使是内部测试版本)?
- 产品在Play Console中是已上线状态,还是仍为草稿?
- 您是否已有服务账户JSON文件,还是需要创建步骤?
如果产品尚未创建,请暂停操作。产品创建属于Play Console的操作,不在本技能范围内。
Phase 2: Plan
阶段2:规划流程
Pick the route that matches the user's state.
| State | Route |
|---|---|
| No RevenueCat account | Start at Step 1, create account and project |
| Account exists, no Android app in project | Start at Step 2, add Android app |
| App exists, Play not connected | Jump to Step 3, upload service account |
| Play connected, no entitlements or offerings | Jump to Step 4 |
| Everything configured, need the API key | Jump to Phase 4 verification |
The default flow below runs end to end. Skip steps the user has already completed.
根据用户当前的状态选择对应的流程路线。
| 当前状态 | 流程路线 |
|---|---|
| 无RevenueCat账户 | 从步骤1开始,创建账户和项目 |
| 已有账户,但项目中无Android应用 | 从步骤2开始,添加Android应用 |
| 应用已存在,但未连接Play | 跳至步骤3,上传服务账户文件 |
| 已连接Play,但未配置权益和产品套餐 | 跳至步骤4 |
| 所有配置已完成,仅需API密钥 | 跳至阶段4的验证环节 |
以下是默认的完整流程。请跳过用户已完成的步骤。
Phase 3: Execute
阶段3:执行配置
Step 1: Create the RevenueCat project and Android app
步骤1:创建RevenueCat项目和Android应用
- Sign up or log in at .
app.revenuecat.com - Create a project. One project can hold Android, iOS, and web apps for the same product.
- Inside the project, add an Android app. Enter the Play Console package name.
RevenueCat generates a public SDK API key per platform. You will copy the Android key at the end. Do not reuse iOS or web keys in the Android app.
- 在 注册或登录账户。
app.revenuecat.com - 创建项目。一个项目可以容纳同一产品的Android、iOS和Web应用。
- 在项目内添加Android应用,输入Play Console中的包名。
RevenueCat会为每个平台生成一个公开SDK API密钥。您将在最后复制Android平台的密钥。请勿在Android应用中复用iOS或Web平台的密钥。
Step 2: Create a Google Cloud service account (if needed)
步骤2:创建Google Cloud服务账户(如需要)
In Google Cloud Console, on the project linked to your Play Console:
- Enable the Google Play Android Developer API.
- Create a service account. Skip role grants on the Cloud side.
- Create a JSON key for the service account and download it.
In Play Console, under Users and permissions:
- Invite the service account email.
- Grant app-level access to the app.
- Grant the Financial data viewer permission. RevenueCat needs it to read subscription state.
在与Play Console关联的Google Cloud Console项目中:
- 启用Google Play Android Developer API。
- 创建服务账户。跳过Cloud端的角色授权步骤。
- 为服务账户创建JSON密钥并下载。
在Play Console的用户与权限模块中:
- 邀请服务账户邮箱。
- 授予该应用的应用级访问权限。
- 授予财务数据查看权限。RevenueCat需要此权限读取订阅状态。
Step 3: Connect Google Play in RevenueCat
步骤3:在RevenueCat中连接Google Play
In the RevenueCat dashboard, open the Android app settings:
- Confirm the package name matches Play Console.
- Upload the service account JSON key file.
- Save.
RevenueCat validates the credential by calling the Play Developer API. If validation fails, the common causes are missing API enablement, wrong project, or the service account not yet propagated in Play (allow up to 24 hours).
在RevenueCat控制台中打开Android应用设置:
- 确认包名与Play Console中的一致。
- 上传服务账户JSON密钥文件。
- 保存设置。
RevenueCat会通过调用Play Developer API验证凭证。如果验证失败,常见原因包括API未启用、项目错误,或者服务账户在Play中的权限尚未生效(最多可能需要24小时)。
Step 4: Create entitlements
步骤4:创建权益(Entitlements)
Entitlements are the access levels your app checks. Define them once, reference them everywhere in client code.
In the dashboard under Entitlements, create one per access tier. Most apps ship with a single entitlement.
| Identifier | Description |
|---|---|
| Unlocks premium features |
| Unlocks team features (second tier, optional) |
Use a stable identifier. Renaming an entitlement later means rewriting every feature gate.
权益是应用中检查的访问级别。只需定义一次,即可在客户端代码的所有位置引用。
在控制台的权益(Entitlements)页面,为每个访问层级创建一个权益。大多数应用只需一个权益。
| 标识符 | 描述 |
|---|---|
| 解锁高级功能 |
| 解锁团队功能(第二层级,可选) |
请使用稳定的标识符。后续重命名权益意味着需要重写所有功能校验逻辑。
Step 5: Import products and attach entitlements
步骤5:导入产品并关联权益
Under Products, click Import. RevenueCat pulls the Play catalog through the connected service account.
- Select each product you want RevenueCat to manage.
- Attach each product to an entitlement. Purchasing the product grants that entitlement.
A single entitlement can back many products (monthly, annual, lifetime all unlock ).
pro_access在产品页面,点击“导入”。RevenueCat会通过已连接的服务账户拉取Play的产品目录。
- 选择需要RevenueCat管理的每个产品。
- 将每个产品关联到一个权益。用户购买该产品后将获得对应的权益。
单个权益可以对应多个产品(月度、年度、终身订阅均可解锁)。
pro_accessStep 6: Create an offering
步骤6:创建产品套餐(Offerings)
Offerings drive what a user sees on the paywall. One offering groups multiple packages.
Under Offerings:
- Create an offering (for example, ).
default - Add packages. Pick a package type (Monthly, Annual, Lifetime, or custom) and assign a product.
- Mark one offering as Current.
The Android SDK fetches to show the default paywall. Swap the current offering later from the dashboard without shipping an app update.
offerings.current产品套餐决定了用户在付费墙中看到的内容。一个产品套餐可以包含多个套餐包。
在产品套餐(Offerings)页面:
- 创建一个产品套餐(例如)。
default - 添加套餐包。选择套餐类型(月度、年度、终身或自定义)并关联一个产品。
- 将一个产品套餐标记为“当前(Current)”。
Android SDK会获取来展示默认付费墙。后续无需发布应用更新,即可在控制台中切换当前产品套餐。
offerings.currentStep 7: Copy the Android API key
步骤7:复制Android API密钥
In the Android app settings, copy the public SDK API key. This value is the second argument to . The skill configuring-the-sdk uses it.
PurchasesConfiguration.Builderkotlin
// Handed off to configuring-the-sdk
val revenueCatApiKey = "goog_xxxxxxxxxxxxxxxxxxxxxxxx"在Android应用设置中,复制公开SDK API密钥。该值是的第二个参数。配置SDK的技能会使用此密钥。
PurchasesConfiguration.Builderkotlin
// Handed off to configuring-the-sdk
val revenueCatApiKey = "goog_xxxxxxxxxxxxxxxxxxxxxxxx"Phase 4: Verify
阶段4:验证配置
Confirm the dashboard and Play Console are wired together before moving to SDK work.
| Check | How to verify | Pass signal |
|---|---|---|
| Service account accepted | RevenueCat app settings, Google Play section | Shows connected with a green indicator |
| Products imported | Products tab in dashboard | Play products appear with live prices |
| Entitlement attachments | Open each product | Shows the attached entitlement |
| Offering current | Offerings tab | One offering tagged Current |
| Package product links | Open the current offering | Each package shows a product identifier |
| API key scope | Project settings, API keys | Android key is distinct from iOS and web keys |
Ask the user to confirm each row. If a product shows no price, the service account is connected but the product is not active in Play. Fix the Play listing, then re-import.
Hand off to rc-configuring-the-sdk with:
- The Android API key
- The current offering identifier
- The entitlement identifiers the app will check
在进入SDK开发前,请确认控制台与Play Console已正确连接。
| 检查项 | 验证方式 | 成功标志 |
|---|---|---|
| 服务账户已通过验证 | RevenueCat应用设置中的Google Play板块 | 显示绿色连接状态标识 |
| 产品已导入 | 控制台的产品页面 | Play产品显示实时价格 |
| 权益已关联 | 打开每个产品页面 | 显示已关联的权益 |
| 产品套餐已设为当前 | 产品套餐页面 | 有一个套餐标记为“当前(Current)” |
| 套餐包与产品已关联 | 打开当前产品套餐 | 每个套餐包显示对应的产品标识符 |
| API密钥范围正确 | 项目设置中的API密钥页面 | Android密钥与iOS、Web密钥区分开 |
请让用户确认每一项。如果产品未显示价格,说明服务账户已连接,但产品在Play中未激活。请修复Play中的产品列表后重新导入。
将以下信息交接给 rc-configuring-the-sdk 技能:
- Android API密钥
- 当前产品套餐标识符
- 应用将检查的权益标识符