@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:

{ "name": "mobile", //... "targets": { //... "build-android": { "executor": "@nx/react-native:build-android", "outputs": [ "{projectRoot}/build/outputs/bundle", "{projectRoot}/build/outputs/apk" ], "options": {} } } }
Nx 15 and lower use @nrwl/ instead of @nx/
nx run mobile:build-android

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.

"build-android": { "executor": "@nx/react-native:build-android", "outputs": [ "{projectRoot}/build/outputs/bundle", "{projectRoot}/build/outputs/apk" ], "options": { "tasks": ["bundleRelease"] } }
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

packager

boolean
Default: true

Launch packager while building

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.

sync

Deprecated
boolean
Default: true

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

Add sync-deps to dependsOn instead