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

在本地创建发布版本

学习如何在本地为你的 Expo 应用创建发布(生产)版本。


要在本地创建你的应用发布版本(也称为生产版本),你需要在计算机上遵循不同的步骤,并使用创建任何原生应用所需的工具。本指南提供了创建 Android 和 iOS 所需的步骤。

🌐 To create your app's release build (also known as production build) locally, you need to follow separate steps on your computer and use the tools required to create any native app. This guide provides the necessary steps for Android and iOS.

安卓

🌐 Android

在本地为 Android 创建发布版本需要使用 上传密钥 对其进行签名,并生成一个 Android 应用包(.aab)。请按照以下步骤操作:

🌐 Creating a release build locally for Android requires signing it with an upload key and generating an Android Application Bundle (.aab). Follow the steps below:

先决条件

2 要求

1.

已安装 OpenJDK

安装 OpenJDK 发行版 以访问 keytool 命令。

2.

安卓目录已生成

如果你正在使用 连续本地生成 (CNG),运行 npx expo prebuild 来生成它。

1

创建上传密钥

🌐 Create an upload key

已经使用 EAS Build 创建了构建?下载你的凭证并跳到下一步。

如果你已经使用 EAS Build 创建了一个构建,请按照以下步骤下载凭证,其中包含上传密钥及其密码、密钥别名和密钥密码:

🌐 If you've already created a build with EAS Build, follow the steps below to download the credentials, which contains the upload key and its password, key alias, and key password:

  1. 在你的终端中,运行 eas credentials -p android 并选择构建配置文件。
  2. 选择 credentials.json > 从 EAS 下载凭证到 credentials.json。
  3. 将下载的 keystore.jks 文件移动到 android/app 目录下。
  4. 从 credentials.json 中复制用于上传 keystore 的密码、密钥别名和密钥密码,因为你在下一步中将需要它们。

在你的 Expo 项目目录中,运行以下 keytool 命令以创建上传密钥:

🌐 Inside your Expo project directory, run the following keytool command to create an upload key:

Terminal
- sudo keytool -genkey -v -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

运行此命令后,系统会提示你输入密钥库的密码。此密码将保护上传密钥。请记住你在此输入的密码,因为下一步你将需要使用它。

🌐 After running this command, you will be prompted to enter a password for the keystore. This password will protect the upload key. Remember the password you enter here, as you'll need it in the next step.

此命令还会在你的项目目录中生成名为 my-upload-key.keystore 的密钥库文件。将其移动到 android/app 目录下。

🌐 This command also generates the keystore file named my-upload-key.keystore in your project directory. Move it to the android/app directory.

2

更新 Gradle 变量

🌐 Update gradle variables

打开 android/gradle.properties 文件,在文件末尾添加以下 gradle 变量。将 ***** 替换为你在上一步中提供的正确密钥库和密钥密码。

🌐 Open android/gradle.properties file and add the following gradle variables at the end of the file. Replace the ***** with the correct keystore and key password that you provided in the previous step.

这些变量包含有关你的上传密钥的信息:

🌐 These variables contain information about your upload key:

android/gradle.properties
# If you've downloaded the credentials from `eas credentials` command, see comments below for each value. # Path to the "keystore" file MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore # Replace with value of the `keystore.keyAlias` field in the credentials.json file MYAPP_UPLOAD_KEY_ALIAS=my-key-alias # Replace with value of the `keystore.password` field in the credentials.json file MYAPP_UPLOAD_STORE_PASSWORD=***** # Replace with value of the `keystore.keyPassword` field in the credentials.json file MYAPP_UPLOAD_KEY_PASSWORD=*****

3

将签名配置添加到 build.gradle

🌐 Add signing config to build.gradle

打开 android/app/build.gradle 文件,并添加以下配置:

🌐 Open android/app/build.gradle file and add the following configuration:

4

Generate release Android Application Bundle (aab)

Navigate inside the android directory and create a release build in .aab format by running Gradle's bundleRelease command:

Terminal
- cd android

- ./gradlew app:bundleRelease

此命令将在 android/app/build/outputs/bundle/release 目录下生成 app-release.aab。

🌐 This command will generate app-release.aab inside the android/app/build/outputs/bundle/release directory.

5

向 Google Play 控制台提交应用

🌐 App submission to Google Play Console

要提交 .aab 文件,请通过 Google Play 控制台手动上传。或者,EAS Submit 接受使用 eas submit --platform android --path ./my-app.aab 本地构建的二进制文件。

🌐 To submit the .aab file, upload it manually through Google Play Console. Alternatively, EAS Submit accepts locally built binaries with eas submit --platform android --path ./my-app.aab.

手动提交 Android 应用

按照逐步指南手动将你的应用首次提交到 Google Play 商店。

iOS

要在本地创建 iOS 发布版本,你需要使用 Xcode,它会处理签名和上传到 App Store Connect。按照手动提交指南,可以完整了解从配置发布方案到归档和上传应用的整个流程:

🌐 To create an iOS release build locally, you use Xcode, which handles signing and uploading to App Store Connect. Follow the manual submission guide for the complete walkthrough, from configuring a release scheme to archiving and uploading your app:

用 Xcode 手动提交 iOS 应用

配置签名,用 Xcode 打包你的应用,然后上传到 App Store Connect。