创建并运行 Android 云构建
了解如何使用 EAS Build 配置 Android 设备和模拟器的开发版本。
在本章中,我们将使用 EAS Build 创建一个可以在 Android 上运行的开发版本。
🌐 In this chapter, we'll create a development build that can run on Android with EAS Build.
在 Android 设备或模拟器上创建和运行构建的过程是相同的,只是开发构建的安装有所不同。
🌐 The process for creating and running a build on Android devices or emulators is identical, with differences only in the installation of the development build.

为开发配置文件创建构建
🌐 Create a build for the development profile
对于 Android,开发版本必须是 .apk 格式。虽然默认的 Android 格式是 .aab,这对于在 Google Play 商店分发是理想的,但它无法安装在设备或模拟器上。
🌐 For Android, the development build must be in the .apk. While the default Android format is .aab, which is ideal for Google Play Store distribution, it cannot be installed on devices or emulators.
要创建 .apk 文件:
🌐 To create a .apk:
-
在 eas.json 中,确保在
build.development配置下将developmentClient设置为true。 -
然后,使用
android作为平台,development作为构建配置运行eas build命令:Terminal-eas build --platform android --profile development信息 提示:下次运行
eas build命令时,你也可以使用-p来指定平台。它是--platform的缩写。
该命令提示我们以下问题:
🌐 This command prompts us with the following questions:
- 你希望你的 Android 应用 ID 是什么? 按 返回 以选择此提示提供的默认值。这将在 app.json 中添加
android.package。 - 生成新的 Android 密钥库?按 Y。
回复后,构建将排队,我们可以通过 EAS CLI 在 EAS 仪表板中提供的链接跟踪其进度:
🌐 After responding, the build will queue up, and we can track its progress via a provided link by the EAS CLI in the EAS dashboard:
构建详情页面包含哪些信息?
构建详细信息页面显示构建类型、配置文件、Expo SDK 版本、应用版本、版本号、最近的提交哈希,以及发起构建的开发者或账户所有者的身份。
🌐 The build details page displays the build type, profile, Expo SDK version, app version, version code, last commit hash, and the identity of the developer or account owner who initiated the build.
在上图中,构建产物的当前状态显示构建正在进行中。完成后,该部分将提供下载构建的选项。日志列出了在 EAS Build 中进行 Android 构建过程的每一个步骤。为了简洁起见,我们这里不会详细探讨每个步骤。欲了解更多信息,请参见 Android 构建过程。
🌐 In the above image, the current status of the Build artifact shows that the build is in progress. Upon completion, this section will offer an option to download the build. The Logs outlines every step taken during the Android build process on EAS Build. For the sake of brevity, we won't explore each step in detail here. To learn more, see Android build process.
什么是安卓应用ID?
也被称为我们 Android 应用的包名,它以 DNS 反向表示法格式(com.owner.appname)存储值。这种表示法的每个部分应以小写字母开头。
🌐 Also known as the package name of our Android app, it stores the value in DNS reverse notation format (com.owner.appname). Each component of this notation should start with a lowercase letter.
例如,我们的示例应用有 com.owner.stickersmash,其中 com.owner 是域名,stickersmash 是我们的应用名称。
🌐 For example, our example app has com.owner.stickersmash where com.owner is the domain and stickersmash is our app name.
安卓设备
🌐 Android device
1
安装开发版本
🌐 Install development build
一旦构建完成,构建产物部分将会更新,表明构建已完成:
🌐 Once the build finishes, the Build artifact section gets updated, indicating that the build is complete:
本节介绍了在 Android 设备上运行开发版本的可用方法:Expo Orbit 和安装按钮。
🌐 This section provides the methods available for running the development build on an Android device: Expo Orbit and Install button.
Expo Orbit 允许在 Android 设备上无缝安装开发版本。使用此方法:
- 使用 USB 将我们的 Android 设备连接到本地电脑。
- 打开 Orbit 菜单栏应用。
- 在 Orbit 应用中选择 设备。
- 在 EAS 仪表板上的 构建产物 下,点击 使用 Orbit 打开。
安装构建后,Orbit 应用会在设备上启动开发构建版本。
🌐 After the build is installed, the Orbit app launches the development build on the device.
2
安卓模拟器
🌐 Android Emulator
1
安装开发版
🌐 Install the development build
在终端中,一旦构建完成,EAS CLI 会提示我们是否要在 Android 模拟器上运行构建。按 Y。
替代:使用 Expo Orbit
或者,可以使用 Expo Orbit 进行安装。在 EAS 仪表板的 构建产物 中,点击 使用 Expo Orbit 打开,即可在 Android 模拟器上安装开发版本。
🌐 Alternatively, Expo Orbit can be used for installation. From Build artifact on the EAS dashboard, click Open with Expo Orbit to install the development build on the Android Emulator.
2
概括
🌐 Summary
Chapter 2: Create and run a cloud build for Android
We successfully used EAS Build to create and run development builds on Android devices and emulators, and learned about .apk and .aab file formats.
In the next chapter, learn how to configure a development build for iOS Simulators using EAS Build and get it running.