提交到 Google Play 商店

了解如何通过计算机和 CI/CD 服务将应用提交到 Google Play Store。


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

¥This guide outlines how to submit your app to the Google Play Store from your computer or from a CI/CD service.

从你的电脑

¥Submitting your app from your computer

Prerequisites

7 requirements

1.

Sign up for a Google Play Developer account

需要 Google Play 开发者账户才能将你的应用提交到 Google Play 商店。你可以在 Google Play 管理中心注册页面 上注册 Google Play 开发者账户。

¥A Google Play Developer account is required to submit your app to the Google Play Store. You can sign up for a Google Play Developer account on the Google Play Console sign-up page.

2.

Create an app on Google Play Console

点击 谷歌游戏控制台 中的“创建应用”创建一个应用。

¥Create an app by clicking Create app in the Google Play Console.

3.

Create a Google Service Account

EAS 要求你上传并配置 Google 服务账户密钥,才能将你的 Android 应用提交到 Google Play 商店。你可以按照 使用 EAS 上传 Google 服务帐号密钥,用于 Play 商店提交 指南创建一个。

¥EAS requires you to upload and configure a Google Service Account Key to submit your Android app to the Google Play Store. You can create one with the uploading a Google Service Account Key for Play Store submissions with EAS guide.

4.

Install EAS CLI and authenticate with your Expo account

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

¥Install EAS CLI and login with your Expo account:

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

5.

Include a package name in app.json

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

¥Include your app's package name in app.json:

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

6.

Build a production app

你需要一个准备好提交到商店的生产版本。你可以使用 EAS 构建 创建一个:

¥You'll need a production build ready for store submission. You can create one using EAS Build:

Terminal
eas build --platform android --profile production

或者,你可以使用 eas build --platform android --profile production --local 或 Android Studio 在自己的计算机上构建应用。

¥Alternatively, you can build the app on your own computer with eas build --platform android --profile production --local or with Android Studio.

7.

Upload your app manually at least once

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

¥You have to upload your app manually at least once. This is a limitation of the Google Play Store API.

请参阅 首次提交 Android 应用 指南了解如何操作。

¥Learn how with the first submission of an Android app guide.

完成所有先决条件后,即可启动提交流程。

¥Once you have completed all the prerequisites, you can start the submission process.

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

¥Run the following command to submit a build to the Google Play Store:

Terminal
eas submit --platform android

该命令将引导你逐步完成提交应用的过程。你可以通过在 eas.json 中添加提交配置文件来配置提交流程。了解你可以在 eas.json 参考 中提供的所有选项。

¥The command will lead you step by step through the process of submitting the app. You can configure the submission process by adding a submission profile in eas.json. Learn about all the options you can provide in the eas.json reference.

要加快提交过程,你可以使用 --auto-submit 标志在构建完成后自动提交构建:

¥To speed up the submission process, you can use the --auto-submit flag to automatically submit a build after it's built:

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

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

¥Learn more about the --auto-submit flag in the automate submissions guide.

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

¥Submitting your app using CI/CD services

Prerequisites

8 requirements

1.

Sign up for a Google Play Developer account

需要 Google Play 开发者账户才能将你的应用提交到 Google Play 商店。你可以在 Google Play 管理中心注册页面 上注册 Google Play 开发者账户。

¥A Google Play Developer account is required to submit your app to the Google Play Store. You can sign up for a Google Play Developer account on the Google Play Console sign-up page.

2.

Create an app on Google Play Console

点击 谷歌游戏控制台 中的“创建应用”创建一个应用。

¥Create an app by clicking Create app in the Google Play Console.

3.

Create a Google Service Account

EAS 要求你上传并配置 Google 服务账户密钥,才能将你的 Android 应用提交到 Google Play 商店。你可以按照 使用 EAS 上传 Google 服务帐号密钥,用于 Play 商店提交 指南创建一个。

¥EAS requires you to upload and configure a Google Service Account Key to submit your Android app to the Google Play Store. You can create one with the uploading a Google Service Account Key for Play Store submissions with EAS guide.

4.

Install EAS CLI and authenticate with your Expo account

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

¥Install EAS CLI and login with your Expo account:

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

5.

Include a package name in app.json

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

¥Include your app's package name in app.json:

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

6.

Provide a submission profile in eas.json

然后,你需要在 eas.json 中提供包含应用 serviceAccountKeyPath 的提交配置文件:

¥Then, you'll need to provide a submission profile in eas.json that includes your app's serviceAccountKeyPath:

eas.json
{
  "submit": {
    "production": {
      "android": {
        "serviceAccountKeyPath": "../path/to/api-xxx-yyy-zzz.json"
      }
    }
  }
}

Android 提交还有其他选项。了解更多信息,请访问 eas.json 参考

¥There are additional options available for Android submissions. Learn more from the eas.json reference.

7.

Build a production app

你需要一个准备好提交到商店的生产版本。你可以使用 EAS 构建 创建一个:

¥You'll need a production build ready for store submission. You can create one using EAS Build:

Terminal
eas build --platform android --profile production

或者,你可以使用 eas build --platform android --profile production --local 或 Android Studio 在自己的计算机上构建应用。

¥Alternatively, you can build the app on your own computer with eas build --platform android --profile production --local or with Android Studio.

8.

Upload your app manually at least once

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

¥You have to upload your app manually at least once. This is a limitation of the Google Play Store API.

请参阅 首次提交 Android 应用 指南了解如何操作。

¥Learn how with the first submission of an Android app guide.

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

¥Once you have completed all the prerequisites, you can set up a CI/CD pipeline to submit your app to the Google Play Store.

使用 EAS Workflows CI/CD

¥Use EAS Workflows CI/CD

你可以使用 EAS 工作流程 自动构建和提交你的应用。

¥You can use EAS Workflows to build and submit your app automatically.

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

    ¥Create a workflow file named .eas/workflows/submit-android.yml at the root of your project.

  2. 在 submit-android.yml 文件中,你可以使用以下工作流程启动提交 Android 应用的作业:

    ¥Inside submit-android.yml, you can use the following workflow to kick off a job that submits an Android app:

.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:
         platform: android
         build_id: ${{ needs.build_android.outputs.build_id }}

上述工作流程将构建 Android 应用,然后将其提交到 Google Play 商店。

¥The workflow above will build the Android app and then submit it to the Google Play Store.

使用其他 CI/CD 服务

¥Use other CI/CD services

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

¥You can use other CI/CD services to submit your app with EAS Submit, like GitHub Actions, GitLab CI, and more by running the following command:

Terminal
eas submit --platform android --profile production

此命令需要 个人访问令牌 来验证你的 Expo 账户。设置完成后,请在 CI/CD 服务中提供 EXPO_TOKEN 环境变量,这将允许 eas submit 命令运行。

¥This command requires a personal access token to authenticate with your Expo account. Once you have one, provide the EXPO_TOKEN environment variable in the CI/CD service, which will allow the eas submit command to run.