@nx/react-native:build-android

Build target options for Android.

Options can be configured in project.json when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.

project.json:

1{ 2 "name": "mobile", 3 //... 4 "targets": { 5 //... 6 "build-android": { 7 "executor": "@nx/react-native:build-android", 8 "outputs": [ 9 "{projectRoot}/build/outputs/bundle", 10 "{projectRoot}/build/outputs/apk" 11 ], 12 "options": {} 13 } 14 } 15} 16
1nx run mobile:build-android 2

Examples

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.

1 "build-android": { 2 "executor": "@nx/react-native:build-android", 3 "outputs": [ 4 "{projectRoot}/build/outputs/bundle", 5 "{projectRoot}/build/outputs/apk" 6 ], 7 "options": { 8 "tasks": ["bundleRelease"] 9 } 10 } 11

Options

mode

string
Default: debug

Specify your app's build variant

activeArchOnly

boolean
Default: false

Build native libraries only for the current device architecture for debug builds.

extraParams

oneOf [Array<string>, string]

Custom params passed to gradle build command

interactive

boolean

Explicitly select build type and flavour to use before running a build

port

number
Default: 8081

The port where the packager server is listening on.

resetCache

boolean
Default: false

Resets metro cache.

tasks

oneOf [Array<string>, string]

Run custom Gradle tasks. By default it's "assembleDebug". Will override passed mode and variant arguments.