Skip to main content

Android Play 商店部署

如果你使用的是 Capacitor,你还可以参考 Capacitor 文档中的 部署到 Google Play

🌐 If you are using Capacitor, you can additionally refer to the Capacitor documentation for Deploying to Google Play.

生成应用的发布版本

🌐 Generating a release build of an app

要为 Android 生成发布版,请先构建你的 Web 应用,然后运行以下 CLI 命令:

npx cap copy && npx cap sync

这将复制所有网络资源并同步所有插件更改。

🌐 This will copy all web assets and sync any plugin changes.

接下来,打开 Android studio:

🌐 Next, open Android studio:

npx cap open android

签署 APK

🌐 Signing an APK

使用 Android Studio 在本地创建 AAB 二进制文件:

  • 打开构建菜单
  • 选择 生成已签名的 Bundle / APK
  • 按照提示使用你的密钥库文件签署 AAB

有关完整详情,请查看 Android 文档

🌐 For complete details, view the Android documentation.

Google Play 签名

🌐 Google Play Signing

如果你尚未切换到 Android 应用包,则需要在 Google Play 控制台中选择加入 Play 应用签名才能发布它们。

🌐 If you haven't made the switch to Android app bundles yet, you will need to opt into Play App Signing in the Google Play Console to be able to publish them.

新应用

🌐 New Apps

首先,在 Google Play 控制台中创建一个新应用。为了启用应用签名,你需要导航到新版本页面,可以在正式发布、开放测试、封闭测试或内部测试页面之一找到。 选择下方所示的“创建新版本”按钮(发布类型无关紧要,因为你现在不需要真正创建一个新版本):

🌐 First, create a new app in the Google Play Console. In order to enable app signing, you'll need to navigate to the new release screen, on one of the Production, Open testing, closed testing, or internal testing pages. Select the Create new release button as seen below (it doesn't matter which release type, since you don't have to actually go through with creating a new release right now):

Google Play Console's Production tab with arrow pointing to the 'Create new release' button.

在应用完整性部分,点击 更改应用签名密钥 按钮:

🌐 Under the App integrity section, click the Change app signing key button:

Google Play Console's App integrity section with the 'Change app signing key' button highlighted.

接下来,选择 从 Java 密钥库导出并上传密钥 选项。这是保留密钥并让 Google Play 使用它进行签名的唯一方式。如果你使用 Appflow 在云端构建 Android 应用,这也是必选的选项,以便将密钥库文件上传到 Appflow。

🌐 Next, select the Export and upload a key from Java Keystore option. This is the only way in which you can retain the key and have Google Play use it for signing. If you're using Appflow to build Android apps in the cloud, this is also the required option so you can upload the keystore file to Appflow.

The Google Play Console showing the option to 'Export and upload a key from Java Keystore'.

按照屏幕上的说明生成 Keystore,你也可以在 Appflow 仪表板中使用相同的 Keystore 文件为你的应用签名。如果你在生成 Keystore 文件时需要任何帮助,可以参考我们的文档 这里

一旦生成的压缩文件上传完成,你就准备好了!使用该 Keystore 文件签名构建 AAB 二进制文件,然后将其上传到 Google Play。

🌐 Follow the instructions on the screen to generate the Keystore and you can use the same Keystore file to sign your app in the Appflow dashboard as well. If you need any help generating the Keystore file, you can refer to our docs here. Once the generated zip file has been uploaded, you're all set! Build an AAB binary signed with the keystore file then upload it to Google Play.

现有应用

🌐 Existing Apps

截至目前,现有应用不需要使用 AAB 格式,但你仍然可以使用 Play 应用签名来注册它们。

🌐 As of now, existing apps aren't required to use the AAB format, but you can still enroll them using Play App signing.

要选择加入应用签名,你需要上传用于签署应用先前版本的应用签名密钥。导航到设置 -> 应用完整性,然后选择下图中看到的两种方法之一。上传密钥后,你即可注册 Play 应用签名。

🌐 To opt into app signing, you'll need to upload the app signing key used to sign previous releases of the app. Navigate to Setup -> App integrity, then choose one of the two methods seen in the screenshot below. Once the key has been uploaded, you can enroll in Play App Signing.

The opt-in options for Play App Signing in the Google Play Console.

tip

由于应用体积更小、性能提升以及安全性增强,AAB 二进制格式对应用开发者和用户来说都是一种胜利。如果你已有使用 APK 格式的 Android 应用,考虑迁移到 AAB,以利用它提供的所有优良功能。

将应用提交到 Google Play 商店

🌐 Submitting an app to the Google Play Store

现在已经生成了发布 AAB/APK,可以编写 Play 商店列表并上传 AAB/APK。

🌐 Now that a release AAB/APK has been generated, a Play Store listing can be written and the AAB/APK can be uploaded.

首先,访问 Google Play 商店开发者控制台 并创建一个新的开发者账户。

🌐 To start, visit the Google Play Store Developer Console and create a new developer account.

note

在 Google Play 上创建开发者账户的费用为 25 美元。

一旦开发者账号创建完成,继续点击 Create an Application

🌐 Once a developer account has been created, go ahead and click the Create an Application

The Google Play Store Developer Console with the 'CREATE APPLICATION' button highlighted.

请务必填写应用的描述,同时提供截图和其他信息。准备好后,上传生成的已签名发布 AAB/APK 并发布应用。

🌐 Be sure to fill out the description for the app along with providing screenshots and additional info. When ready, upload the signed release AAB/APK that was generated and publish the app.

更新应用

🌐 Updating an app

随着应用的发展,它需要通过添加新功能和修复来进行更新。应用可以通过提交新版本到 Google Play 商店,或者使用像 Appflow 的实时更新功能这样的实时更新服务来进行更新。使用实时更新,可以直接从 Appflow 仪表板向用户推送更改,而无需向 Play 商店提交更改。了解有关实时更新的更多信息 这里

note

为了让 Google Play 商店接受更新的 AAB/APK,需要编辑 android/app/build.gradle 文件以增加 versionCode 值,然后按照上述说明重新构建应用以发布。