project.json:

1{ 2 "name": "mobile", 3 //... 4 "targets": { 5 //... 6 "run-android": { 7 "executor": "@nx/react-native:run-android", 8 "options": {} 9 } 10 } 11} 12
Nx 15 and lower use @nrwl/ instead of @nx/
1nx run mobile:run-android 2

Examples

To see all the avaiable emulators, run command:

1emulator -list-avds 2

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

1 "run-android": { 2 "executor": "@nx/react-native:run-android", 3 "options": { 4 "deviceId": "Pixel_5_API_30" 5 } 6 } 7
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.