project.json:

{ "name": "mobile", //... "targets": { //... "run-android": { "executor": "@nx/react-native:run-android", "options": {} } } }
Nx 15 and lower use @nrwl/ instead of @nx/
nx run mobile:run-android

Examples

To see all the avaiable emulators, run command:

emulator -list-avds

The deviceId option allows you to launch your android app in a specific device/simulator:

"run-android": { "executor": "@nx/react-native:run-android", "options": { "deviceId": "Pixel_5_API_30" } }
Nx 15 and lower use @nrwl/ instead of @nx/

Options

mode

string
Default: debug

Specify your app's build variant

appId

string

Specify an applicationId to launch after build. If not specified, package from AndroidManifest.xml will be used.

appIdSuffix

string

Specify an applicationIdSuffix to launch after build.

activeArchOnly

boolean
Default: false

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

binaryPath

string

Path relative to project root where pre-built .apk binary lives.

deviceId

string

Builds your app and starts it on a specific device/simulator with the given device id (listed by running adb devices on the command line).

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

listDevices

boolean

Lists all available Android devices and simulators and let you choose one to run the app

mainActivity

string
Default: MainActivity

Name of the activity to start.

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.

jetifier

Deprecated
boolean

Run Jetifier – the AndroidX transition tool. By default it runs before Gradle to ease working with libraries that don't support AndroidX yet.

Deprecated from @react-native-community/cli. Will be remove in Nx 17.

sync

Deprecated
boolean
Default: true

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

Add sync-deps to dependsOn for this target in project.json instead

variant

Deprecated
string
Default: debug

Specify your app's build variant (e.g. debug, release).

Deprecated from @react-native-community/cli, use mode instead, e.g. mode=debug. Will be remove in Nx 17.