packages/react-native/docs/build-android-examples.md
project.json:
{
"name": "mobile",
//...
"targets": {
//...
"build-android": {
"executor": "@nx/react-native:build-android",
"outputs": [
"{projectRoot}/build/outputs/bundle",
"{projectRoot}/build/outputs/apk"
],
"options": {}
}
}
}
nx run mobile:build-android
The tasks option accepts any custom gradle task, such as assembleDebug, assembleRelease, bundleDebug, bundleRelease, installDebug, installRelease.
For example, pass in bundleRelease or bundleRelease to tasks, it will create with .aab extension under bundle folder.
Pass in assembleDebug or assembleRelease to tasks, it will create a build with .apk extension under apk folder.
Pass in installDebug or installRelease to tasks, it will create a build with .apk extension and immediately install it on a running emulator or connected device.
"build-android": {
"executor": "@nx/react-native:build-android",
"outputs": [
"{projectRoot}/build/outputs/bundle",
"{projectRoot}/build/outputs/apk"
],
"options": {
"tasks": ["bundleRelease"]
}
}
The mode option allows you determine whether to build for debug/release apk.
"build-android": {
"executor": "@nx/react-native:build-android",
"outputs": [
"{projectRoot}/build/outputs/bundle",
"{projectRoot}/build/outputs/apk"
],
"options": {
"mode": "debug"
}
}
The activeArchOnly option allows you to build native libraries only for the current device architecture for debug builds.
"build-android": {
"executor": "@nx/react-native:build-android",
"outputs": [
"{projectRoot}/build/outputs/bundle",
"{projectRoot}/build/outputs/apk"
],
"options": {
"activeArchOnly": true
}
}