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 要求
2 要求
1.
安装 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:
- 在你的终端中,运行
eas credentials -p android并选择构建配置文件。 - 选择 credentials.json > 从 EAS 下载凭证到 credentials.json。
- 将下载的 keystore.jks 文件移动到 android/app 目录下。
- 从 credentials.json 中复制用于上传 keystore 的密码、密钥别名和密钥密码,因为你在下一步中将需要它们。
在你的 Expo 项目目录中,运行以下 keytool 命令以创建上传密钥:
🌐 Inside your Expo project directory, run the following keytool command to create an upload key:
运行此命令后,系统会提示你输入密钥库的密码。此密码将保护上传密钥。请记住你在此输入的密码,因为下一步你将需要使用它。
🌐 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.
警告 如果你将 android 目录提交到像 Git 这样的版本控制系统,请不要提交此 keystore 文件。它包含你的上传密钥,应保持私密。
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 目录提交到像 Git 这样的版本控制系统,不要提交上述信息。相反,请在你的电脑上创建一个 ~/.gradle/gradle.properties 文件,并将上述变量添加到该文件中。
3
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:
此命令将在 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.
按照逐步指南手动将你的应用首次提交到 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 打包你的应用,然后上传到 App Store Connect。