@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
Nx 15 and lower use @nrwl/ instead of @nx/
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
Nx 15 and lower use @nrwl/ instead of @nx/

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.

apk

Deprecated
boolean

Generate apk file(s) rather than a bundle (.aab).

Use tasks option instead, e.g. tasks=['bundleRelease'] to generate aab, tasks=['assembleDebug'] to generate apk. Will be removed in Nx 17.

debug

Deprecated
boolean

Generate a debug build instead of a release build.

Use mode option instead, e.g. mode='debug'. Deprecated from @react-native-community/cli. Will be removed in Nx 17.

gradleTask

Deprecated
string

Override default gradle task incase of multi build variants

Use tasks option instead, e.g. tasks=['assembleDebug']. Will be removed in Nx 17.

packager

Deprecated
boolean
Default: true

Launch packager while building

Run nx run <project>:start instead. Will be removed in Nx 17.

sync

Deprecated
boolean
Default: true

Syncs npm dependencies to package.json (for React Native autolink).

Add sync-deps to dependsOn instead