提交到 Google Play 商店

编辑页面

了解如何从你的电脑和 CI/CD 服务将应用提交到 Google Play 商店。


For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.

本指南概述了如何从您的计算机或从 CI/CD 服务将您的应用提交到 Google Play Store。

从您的计算机提交您的应用

Prerequisites

7 requirements

1.

注册 Google Play 开发者账号

提交您的应用到 Google Play Store 需要一个 Google Play 开发者账号。您可以在 Google Play Console 注册页面 上注册 Google Play 开发者账号。

2.

在 Google Play Console 中创建应用

通过在 Google Play Console 中点击 Create app 来创建应用。

3.

创建 Google 服务账号

EAS 需要您上传并配置一个 Google 服务账号密钥,才能将您的 Android 应用提交到 Google Play Store。您可以使用 使用 EAS 为 Play Store 提交上传 Google Service Account Key 指南来创建一个。

4.

安装 EAS CLI 并使用您的 Expo 账号进行认证

安装 EAS CLI 并使用您的 Expo 账号登录:

Terminal
npm install -g eas-cli && eas login

5.

在 app.json 中包含包名

app.json 中包含您的应用包名:

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

6.

构建生产版本应用

您需要一个可用于商店提交的生产版本构建。您可以使用 EAS Build 创建一个:

Terminal
eas build --platform android --profile production

另外,您也可以使用 eas build --platform android --profile production --local 在自己的电脑上构建应用,或者使用 Android Studio。

7.

至少手动上传一次您的应用

您必须至少手动上传一次应用。这是 Google Play Store API 的限制。

了解更多请参阅 Android 应用的首次提交 指南。

完成所有先决条件后,您就可以开始提交流程了。

运行以下命令将构建提交到 Google Play Store:

Terminal
eas submit --platform android

该命令会一步一步引导您完成提交应用的过程。您可以通过在 eas.json 中添加提交配置文件来配置提交流程。有关您可以提供的所有选项,请参阅 eas.json 参考

为了加快提交流程,您可以使用 --auto-submit 标志在构建完成后自动提交构建:

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

有关 --auto-submit 标志的更多信息,请参阅 自动化提交 指南。

使用 CI/CD 服务提交您的应用

Prerequisites

8 requirements

1.

注册 Google Play 开发者账号

提交您的应用到 Google Play Store 需要一个 Google Play 开发者账号。您可以在 Google Play Console 注册页面 上注册 Google Play 开发者账号。

2.

在 Google Play Console 中创建应用

通过在 Google Play Console 中点击 Create app 来创建应用。

3.

创建 Google 服务账号

EAS 需要您上传并配置一个 Google 服务账号密钥,才能将您的 Android 应用提交到 Google Play Store。您可以使用 使用 EAS 为 Play Store 提交上传 Google Service Account Key 指南来创建一个。

4.

安装 EAS CLI 并使用您的 Expo 账号进行认证

安装 EAS CLI 并使用您的 Expo 账号登录:

Terminal
npm install -g eas-cli && eas login

5.

在 app.json 中包含包名

app.json 中包含您的应用包名:

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

6.

将您的 Google 服务账号密钥上传到 EAS 控制台

然后,您需要在项目的凭据下将您的 Google 服务账号密钥上传到 EAS 控制台。

  • 前往您项目的 EAS 控制台,点击 Credentials,然后在 Android 下点击您应用的 Application identifier
  • Service Credentials 下,点击 Add a Google Service Account Key
  • Change Google Service Account Key 下,确保已选择 Upload new key,并上传下载的 JSON 密钥。这将把该密钥添加到您项目的凭据中。

您也可以使用 EAS CLI 将 JSON 密钥上传到 EAS 控制台:

  • 运行 eas credentials --platform android
  • 当提示 Which build profile do you want to configure? 时,选择 production
  • 当提示 What do you want to do? 时,选择 Google Service Account > Upload a Google Service Account Key
  • 然后添加 JSON 密钥文件路径以将文件上传到 EAS 控制台

7.

构建生产版本应用

您需要一个可用于商店提交的生产版本构建。您可以使用 EAS Build 创建一个:

Terminal
eas build --platform android --profile production

另外,您也可以使用 eas build --platform android --profile production --local 在自己的电脑上构建应用,或者使用 Android Studio。

8.

至少手动上传一次您的应用

您必须至少手动上传一次应用。这是 Google Play Store API 的限制。

了解更多请参阅 Android 应用的首次提交 指南。

完成所有先决条件后,您就可以设置 CI/CD 流水线将您的应用提交到 Google Play Store。

使用 EAS Workflows CI/CD

您可以使用 EAS Workflows 自动构建并提交您的应用。

  1. 在项目根目录下创建一个名为 .eas/workflows/submit-android.yml 的工作流文件。

  2. submit-android.yml 中,您可以使用以下工作流来启动一个提交 Android 应用的任务:

    .eas/workflows/submit-android.yml
    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 }}

    上面的工作流将构建 Android 应用,然后将其提交到 Google Play Store。

使用其他 CI/CD 服务

您可以通过运行以下命令,使用其他 CI/CD 服务通过 EAS Submit 提交您的应用,例如 GitHub Actions、GitLab CI 等:

Terminal
eas submit --platform android --profile production

此命令需要一个 个人访问令牌 来使用您的 Expo 账号进行认证。一旦您拥有令牌,请在 CI/CD 服务中提供 EXPO_TOKEN 环境变量,这将允许 eas submit 命令运行。