This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

用 EAS Submit 提交到 Google Play 商店

了解如何使用 EAS Submit 将你的 Android 应用提交到 Google Play 商店。


EAS 提交 是上传你的 Android 应用到 Google Play 商店的推荐方式。eas submit 命令在你的机器上和 CI/CD 中的工作方式是一样的。EAS 工作流程 是在构建后自动运行它的最简单方法。

先决条件

🌐 Prerequisites

先决条件

5 要求

1.

注册 Google Play 开发者账号

要将你的应用提交到 Google Play 商店,需要一个 Google Play 开发者账号。在Google Play 控制台注册页面注册。

2.

在 Google Play 控制台创建应用

在Google Play 控制台中点击 创建应用 来创建一个应用。

3.

创建一个谷歌服务账号密钥并上传到 EAS

EAS 需要一个 Google 服务账号密钥来代表你提交。请按照创建 Google 服务账号密钥指南来创建一个。然后,通过 EAS 仪表板或 EAS CLI 上传该密钥并将其分配给你的应用:

  • 进入你项目的 EAS 仪表板,点击 Credentials,在 Android 下,点击你应用的 Application identifier。
  • 在 服务凭据 下的 EAS 提交的 Google 服务账号密钥 中,点击 添加 Google 服务账号密钥。
  • 确保选择了上传新密钥,上传下载的 JSON 密钥,然后点击保存。

EAS 会把密钥存储在你的 Expo 账户里。你可以给每个 Android 应用标识符分配一个密钥。如果想在账户里的另一个应用上使用相同的密钥,可以在 EAS 仪表板里选择 选择已保存的密钥。在 EAS CLI 中,选择 为 Play 商店提交选择一个现有的 Google 服务账号密钥。

4.

在应用配置中包含一个包名

在 app.json 中包含你的应用包名:

app.json
{ "android": { "package": "com.yourcompany.yourapp" } }

5.

安装 EAS CLI 并使用你的 Expo 账户进行身份验证

安装 EAS CLI 并使用你的 Expo 账户登录:

Terminal
- npm install --global eas-cli && eas login
- yarn global add eas-cli && eas login
- pnpm add --global eas-cli && eas login
- bun add --global eas-cli && eas login

构建一个生产应用

🌐 Build a production app

你需要一个生产用的 .aab(Android 应用包)来提交。Google Play 要求新应用以应用包的形式发布,而不是 .apk 文件,并会根据应用包为每个设备生成优化后的 APK。用 EAS Build 创建一个吧:

🌐 You need a production .aab (Android App Bundle) to submit. Google Play requires new apps to be published as app bundles instead of .apk files, and generates optimized APKs for each device from the bundle. Create one with EAS Build:

Terminal
- eas build --platform android --profile production

或者,你可以在自己的电脑上用 eas build --platform android --profile production --local 或者用 Android Studio 构建。

🌐 Alternatively, build on your own computer with eas build --platform android --profile production --local or with Android Studio.

默认的 production 配置会生成 .aab 文件。只有当构建配置将 android.buildType 设置为 apk 时,它才会生成 .apk 文件,这在 在模拟器或设备上安装 时很有用,但不能提交到 Google Play 商店。

🌐 The default production profile produces a .aab. A build profile only produces a .apk when it sets android.buildType to apk, which is useful for installing on an emulator or device but cannot be submitted to the Google Play Store.

首次提交

🌐 First-time submission

如果这是你应用的首次提交,默认的 eas submit 命令开箱即用,会在内部测试轨道上创建你的应用的第一个版本。在运行它之前,先完成先决条件,确保你的应用已存在于 Google Play 控制台中,并且 EAS 拥有一个Google 服务账户密钥来代表你提交应用。在你完成商店列表和设置任务之前,应用在 Play 控制台中会保持草稿状态,而这些任务是在将版本发布到生产环境之前必须完成的。

🌐 If this is your app's first submission, the default eas submit command works out of the box and creates your app's first release on the internal testing track. Before running it, complete the prerequisites so that your app exists on Google Play Console and EAS has a Google Service Account key to submit on your behalf. The app stays in draft status in Play Console until you complete the store listing and setup tasks, which are required before a release can be promoted to production.

  • 更喜欢自己上传第一次吗? 按照 手动提交指南 在 Play 控制台创建第一次发布。
  • 想上传但不立即发布? 在 eas.json 的提交配置文件中,将 releaseStatus 设置为 draft,然后在 Play 控制台完成发布。

使用 eas submit 提交

🌐 Submit with eas submit

一旦构建完成,就把它提交到 Google Play 商店吧:

🌐 Once the build is ready, submit it to the Google Play Store:

Terminal
- eas submit --platform android

该命令会引导你选择一个构建并上传它。通过在 eas.json 中添加提交配置来设置提交流程。有关所有可用选项,请参见 eas.json 参考。

🌐 The command will walk you through selecting a build and uploading it. Configure the submission process by adding a submission profile in eas.json. See the eas.json reference for every available option.

一步构建并提交

🌐 Build and submit in one step

把 --auto-submit 传给 eas build,让 EAS Submit 自动接收完成的构建:

🌐 Pass --auto-submit to eas build to hand the finished build off to EAS Submit automatically:

Terminal
- eas build --platform android --auto-submit

详情请参见 自动提交。

🌐 See Automate submissions for details.

使用 EAS 工作流程实现自动化

🌐 Automate with EAS Workflows

EAS 工作流 在 EAS 基础设施上运行相同的 eas submit 命令,可以由 git push 触发,也可以从命令行手动运行。工作流使用你在 先决条件 中上传的 Google 服务账号密钥进行 Google Play 验证。

创建一个名为 .eas/workflows/submit-android.yml 的工作流文件,内容如下:

🌐 Create a workflow file named .eas/workflows/submit-android.yml with the following contents:

.eas/workflows/submit-android.yml
name: Submit Android on: push: branches: ['main'] jobs: build_android: name: Build Android app type: build params: platform: android profile: production submit_android: name: Submit to Google Play Store needs: [build_android] type: submit params: profile: production build_id: ${{ needs.build_android.outputs.build_id }}

这会在每次推送到 main 时构建一个安卓应用并提交到 Google Play。可以手动触发它,方法是:

🌐 This builds an Android app on every push to main and submits it to Google Play. Trigger it manually with:

Terminal
- eas workflow:run submit-android.yml

查看更多模式,请参考工作流示例指南。

🌐 See the workflow examples guide for more patterns.

使用其他 CI/CD 服务

🌐 Use other CI/CD services

你可以在任何 CI/CD 服务上运行 eas submit,比如 GitHub Actions、GitLab CI 等等:

🌐 You can run eas submit from any CI/CD service, such as GitHub Actions, GitLab CI, and others:

Terminal
- eas submit --platform android --profile production

这需要一个 个人访问令牌 来验证你的 Expo 账户。在你的 CI 服务中设置 EXPO_TOKEN 环境变量,这样 eas submit 就可以非交互式运行了。

🌐 This requires a personal access token to authenticate with your Expo account. Set the EXPO_TOKEN environment variable in your CI service so eas submit can run non-interactively.

使用 --non-interactive 时,eas submit 和 eas build --auto-submit 无法提示你输入 Google 服务账号密钥。除非你的提交配置设置了 serviceAccountKeyPath,否则它们会使用分配给你应用的密钥。如果没有分配密钥,就会报以下错误:

🌐 With --non-interactive, eas submit and eas build --auto-submit cannot prompt you for a Google Service Account key. Unless your submission profile sets serviceAccountKeyPath, they use the key that is assigned to your app. If no key is assigned, they fail with the following error:

Google Service Account Keys cannot be set up in --non-interactive mode.

要解决这个问题,按照前提条件中的说明给你的应用分配一个密钥。你也可以将 serviceAccountKeyPath 设置为 CI 机器上密钥文件的路径。

🌐 To fix this, assign a key to your app as described in Prerequisites. You can also set serviceAccountKeyPath to the path of a key file on the CI machine.