React-Native: error Failed to install the app. Make sure you have an Android emulator running
Asked Answered
T

8

6

I just initialized a new React Native project via:

react-native init AwesomeProject

and I am already getting this error:

BUILD FAILED in 3s

error Failed to install the app. Make sure you have an Android emulator running or a device connected. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went 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 or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s

    at checkExecSyncError (child_process.js:637:11)
    at execFileSync (child_process.js:655:13)
    at runOnAllDevices (/Users/danale/Projects/engageMobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
    at buildAndRun (/Users/danale/Projects/engageMobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:169:41)
    at then.result (/Users/danale/Projects/engageMobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:135:12)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

It is a boilerplate app only thus far. I am using zsh and not bash for command line interface.

I also develop in flutter and I do not get this problem, it opens up the Nexus 5X simulator without a hitch.

What could be the problem?

I tried changing permissions, but that is not it.

Transparent answered 18/7, 2019 at 14:42 Comment(0)
T
5

So apparently I have more experience with ios than android and while react-native run-ios automatically opens up a simulator for you, react-native run-android does not, important point, similar commands, don't do similar things, i.e. open up a simulator.

Once I opened up the application inside of Android Studio and then went to AVD Manager and opened up the simulator for Android Studio and then ran react-native run-android, it worked perfectly.

Transparent answered 18/7, 2019 at 16:33 Comment(1)
I am running windows 10 and I am geting Intel HAXM is required to run this AVD. VT-x is disabled in BIOS. They say y0u can not enable hyper v in windows 10 any soultion ?Hypochondriasis
S
3

None of the above worked for me when I start a new project try this

go to android folder and edit build.gradle

set buildToolsVersion = "23.0.1" mine was 30.0.2 when i changed it to "23.0.1" it started working

In the android folder run

gradlew.bat installDebug

and make sure the Build is successful

enter image description here

That should do it go back to your project folder and run

npm run android
Stroll answered 7/3, 2022 at 9:27 Comment(0)
D
1

Make sure your Android simulator is running. Close ALL terminal window. Run 'react-native run-android' It's should open two terminal windows. If you see a same error again, close the second terminal ( the one where is compile), and run 'npm start' in 1 open terminal.

Definiendum answered 18/7, 2019 at 15:54 Comment(1)
dimonD, what does that accomplish? It simply opens up Metro Bundler again, but the issue is not resolved.Transparent
K
1

For those who are cloning directly from a repo that was in another PC:
Just set permissions to modify in the entire project folder, without it, the system can not use the executables such as: gradlew...

sudo chmod -R 777 ./

(I use this cause' I know the risk, but you can use 644.

Knighthood answered 15/10 at 19:36 Comment(0)
C
0

If your nodejs already running or any device is already connected before init project then it wont be considered for react-native.

Cline answered 18/7, 2019 at 14:58 Comment(0)
E
0

I ran across the same problem. Even though my android simulator works fine, once in a while, some corruption occurs, and then react-native run-android throws above error.

One solution that works for me is to close all command prompts, close the virtual devices and re-run them fresh, always worked for me.

Estovers answered 24/8, 2019 at 2:45 Comment(0)
W
0

Basically open your react native project in android studio, and it will download gradle in android studio instead of the command terminal. then open your command terminal and run the code "npm run android" and it shall work

Waler answered 4/4, 2022 at 18:56 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewNihil
L
-2

I think you forgot to create virtual device first.

  1. open android studio application
  2. chose configure icon and then select AVD Manager
  3. create your virtual device here.

after finish, you can run on cmd/terminal npx react-native run-android

Leftist answered 20/1, 2021 at 7:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.