Error when attempting to launch andorid app with react-native

Asked 2 years ago, Updated 2 years ago, 161 views

[I answered this question myself]

When I try to launch the Android app with react-native, I get the following error

$react-native run-android
Starting JS server...
Building and installing the app on the device (cd android & ./gradlew installDebug) ...
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
.
.
.
:app:zipalignDebug UP-TO-DATE
:app:assemblyDebug UP-TO-DATE
:app:installDebug FAILED

FAILURE—Build failed with an exception.

* What was wrong:
Execution failed for task ':app:installDebug'.
>com.android.builder.testing.api.DeviceException: No connected devices!

* Try:
Run with --stacktrace option to get the stack trace. Run with -- info -- debug option to get more log output.

BUILD FAILED

Total time: 17.053 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
setup your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

What is the cause of this?

react-native

2022-09-30 21:12

1 Answers

Error due to missing virtual device

>com.android.builder.testing.api.DeviceException: No connected devices!

This means that the virtual device is not found on the network and cannot be connected to the device.
Even if you actually look for an Android device,

$adb devices
List of devices attached

will be

Start the Android virtual device.
GenyMotion is recommended as an Android virtual device emulator.

Then, in the host operating system,

$adb devices
List of devices attached
192.168.56.101—5555 device

Neighboring devices will appear on the network.

$react-native run-android

Launch Android in

See here


2022-09-30 21:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.