为 Android 创建生产版本
了解为 Android 创建生产版本和自动化发布过程的过程。
在本章中,我们将创建示例应用的生产版本并将其提交到 Google Play 商店。我们还将探讨如何自动化创建和发布新应用版本。
🌐 In this chapter, we'll create our example app's production version and submit it to the Google Play Store. We'll also explore how to automate the creation and release of new app versions.

先决条件
🌐 Prerequisites
要在 Google Play 商店上发布和分发应用,我们需要:
🌐 To publish and distribute an app on the Google Play Store, we need:
- Google Play 开发者账号: 必须拥有付费开发者账号。有关如何设置账号的详细信息,请访问 Google Play 注册页面。
- Google 服务账号密钥: 我们需要一个 Google 服务账号的邮箱和 JSON 密钥来自动化应用提交流程。请按照我们指南中关于创建 Google 服务账号密钥或从现有账号下载 的详细说明操作,然后返回本指南。 这是可选的,但对于自动发布流程 是必需的。
- 生产构建配置: 确保在你的 eas.json 中存在
production构建配置,它是默认添加的。
Android 的生产版本
🌐 Production build for Android
一个生产 Android 构建采用 .aab 格式,这种格式经过优化,可用于在 Google Play 商店分发。与 .apk 构建不同,.aab 文件只能通过 Google Play 商店分发和安装。
🌐 A production Android build has a .aab format which is optimized for distribution on the Google Play Store. Unlike .apk builds, .aab files can only be distributed and installed through the Google Play Store.
1
创建生产版本
🌐 Create a production build
要使用默认的 production 配置创建 Android 生产构建,请打开终端并执行以下命令。由于 production 已在 EAS 配置中设置为默认配置,因此无需使用 --profile 标志显式指定它。
🌐 To create an Android production build using the default production profile, open your terminal and execute the following command. Since production is set as the default profile in the EAS configuration, there is no need to specify it explicitly with the --profile flag.
- eas build --platform android上述命令将把构建排入队列。在 EAS 仪表板中注意 版本代码 是自动递增的。
🌐 The above command will queue the build. Notice in the EAS dashboard that the Version Code is auto-incremented.
2
3
发布内部测试版本
🌐 Release an internal testing version
在 Google Play 控制台创建应用后,它会将我们重定向到应用的仪表板屏幕。我们需要准备应用的内部测试版本。
🌐 After the app is created on Google Play Console, it redirects us to the app's Dashboard screen. We need to prepare an internal test version of our app.
- 在 仪表板 上点击 立即开始测试。
- 创建一个电子邮件列表,包含 内部测试 > 内部测试版本的测试人员 下的用户。
- Google Play 控制台提示我们创建内部测试版本。
- 要创建新版本,请转到 仪表板 并点击 创建新版本。你会首先注意到签名密钥已由 Google Play 控制台在 应用完整性 下自动生成。
4
5
分享内部发布版本
🌐 Share the internal release version
在曲目摘要下,我们看到最新版本显示了一个临时的应用名称。这是因为我们的应用尚未经过审核。
🌐 Under Track Summary, we see that the latest release shows a temporary app name. This is because our app is not reviewed yet.
在版本下,我们可以看到该应用可供内部测试人员使用。要与测试团队共享该应用,请执行以下操作:
🌐 Under Releases, we see that the app is available to internal testers. To share the app with a team of testers:
- 切换到 Releases 旁边的 测试人员 标签。
- 点击 如何让测试人员加入你的测试 下的 复制链接。你可以使用此链接通过电子邮件或消息与你的测试团队分享。
- 在设备上打开测试邮件,并按照步骤下载应用。
- 测试邮箱持有者需要接受邀请,一旦接受,应用就可以安装到设备上。
信息 提示:要在 Play 商店发布应用,请在 Google 控制台中完成 设置你的应用 下的步骤。这些步骤是在第一次将应用发布到 Play 商店之前必须完成的。你需要提供的信息包括隐私政策链接、目标受众、数据安全等内容。
完整的应用商店列表:要为应用准备商店列表,请参阅 创建应用商店资源 了解如何创建截图和预览。
6
添加 Google 服务账号权限密钥
🌐 Add Google Service Account permissions key
信息 提示:在按照本节的步骤操作之前,请查看关于创建 Google 服务账号密钥或从现有账号下载的指南。
从现在起,我们可以使用 EAS Submit 来自动化发布,避免手动操作。为此,我们需要将服务账户密钥添加到我们项目的凭据中。
🌐 From now on, we can use EAS Submit to automate releases and avoid the manual process. To do that, we need to add the service account key to our project's credentials.
按照 Google 服务账号指南的步骤操作后,我们可以将下载的 JSON 密钥上传到 EAS 仪表板:
🌐 After following the Google Service Account guide steps, we can upload the downloaded JSON key to EAS dashboard:
- 进入你项目的 EAS 仪表板,点击 Credentials,在 Android 下,点击你应用的 Application identifier。
- 在 服务凭据 下,点击 添加 Google 服务账户密钥。
- 在 更改 Google 服务账户密钥 下,确保选择 上传新密钥 并上传下载的 JSON 密钥。这将把密钥添加到你项目的凭据中。
7
内部发布
🌐 Internal release
让我们在 eas.json 中将轨道设置为 internal。
🌐 Let's set the track to internal in eas.json.
- 在
submit.production配置文件下,将track设置为internal:
{ %%placeholder-start%%... %%placeholder-end%% "submit": { "production": { "android": { "track": "internal" } } } }
在上面的代码片段中,我们添加了 track 属性并将其值设置为 internal。这将使 eas submit 命令能够上传我们的生产版本并在 Google Play 商店进行内部测试发布。
🌐 In the above snippet, we're adding track property and setting its value to internal. This will enable the eas submit command to upload our production build and release it for internal testing on the Google Play Store.
- 现在运行
eas submit命令来发布一个新的内部测试版本:
- eas submit --platform android- 此命令将自动在 Google Play 控制台中创建一个新的内部发布版本:
8
正式发布
🌐 Production release
要发布应用到生产环境:
🌐 To release the app for production:
- 在 eas.json 中将
track的值改为production:
{ %%placeholder-start%%... %%placeholder-end%% "submit": { "production": { "android": { "track": "production" } } } }
- 我们也可以使用相同的 EAS Build 来进行内部测试发布。运行
eas submit命令将其发布到 Play 商店:
- eas submit --platform android- 要创建一个版本并将我们的应用提交到 Google Play 商店的审核流程,我们需要进入 测试与发布 > 正式发布,然后在 版本 下选择我们想要提交审核的构建。
9
自动发布
🌐 Automated release
在以后的后续版本中,我们可以通过使用 eas build 的 --auto-submit 标志,将构建创建和 Play 商店提交合并为一个步骤,从而简化流程:
🌐 For subsequent releases in future, we can streamline the process by combining build creation and Play Store submission into a single step by using the --auto-submit flag with eas build:
- eas build --platform android --auto-submit概括
🌐 Summary
Chapter 8: Create a production build for Android
We successfully created a production-ready Android build, discussed manual and automated uploading to Google Play Store using eas submit, and automated the release process with the --auto-submit.
In the next chapter, learn about the process of creating a production build for iOS.