Skip to main content

Android Play 商店部署

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

¥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 命令:

¥To generate a release build for Android, build your web app and then run the following cli command:

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 二进制文件:

¥To create an AAB binary locally using Android Studio:

  • 打开构建菜单

    ¥Open the Build menu

  • 选择生成签名包/APK

    ¥Choose Generate Signed Bundle / APK

  • 按照提示使用你的密钥库文件签署 AAB

    ¥Follow the prompts to sign the AAB with your keystore file

如需完整详细信息,查看 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 Console 中创建一个新应用。为了启用应用签名,你需要导航到新发布屏幕的“生产”、“开放测试”、“封闭测试”或“内部测试”页面之一。选择“创建新版本”按钮,如下所示(哪种版本类型并不重要,因为你现在不必实际创建新版本):

¥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):

Select create new release in Google Play Console's Production tab

在“应用完整性”部分下,单击“更改应用签名密钥”按钮:

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

Select change app signing key in Google Play Console's Production tab

接下来,选择从 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.

Uploading a keystore file to Google Play Console

按照屏幕上的说明生成密钥库,你也可以使用相同的密钥库文件在 Appflow 仪表板中对你的应用进行签名。如果你在生成密钥库文件时需要任何帮助,可以参考我们的文档 此处。上传生成的 zip 文件后,一切就完成了!构建使用密钥库文件签名的 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.

App integrity setup in Google Play Console

提示

AAB 二进制格式具有更小的应用大小、更高的性能和更高的安全性,对于应用开发者和用户来说都是一种胜利。如果你现有的 Android 应用使用 APK 格式,请考虑迁移到 AAB 以利用它提供的所有强大功能。

¥With smaller app sizes, improved performance, and enhanced security, the AAB binary format is a win for app developers and users alike. If you have an existing Android app using the APK format, consider migrating to AAB to take advantage of all the great features it provides.

将应用提交到 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.

注意

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

¥Making a developer account with Google Play costs $25 USD.

创建开发者账户后,继续并单击 Create an Application

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

Create an App button

请务必填写应用的说明,并提供屏幕截图和其他信息。准备就绪后,上传生成的签名版本 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 商店。了解有关实时更新 here 的更多信息。

¥As an app evolves, it will need to be updated with new features and fixes. An app can be updated by either submitting a new version to the Google Play Store, or by using a live update service like Appflow's Live Update feature. Using Live Updates, changes can be pushed directly to users from the Appflow dashboard, without submitting changes to the Play Store. Learn more about Live Updates here.

注意

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

¥In order for the Google Play Store to accept updated AAB/APK, the android/app/build.gradle file will need to be edited to increment the versionCode value, then rebuild the app for release following the instructions above.