The first time I run my react-native app the emulator works (using Android Studio Galaxy Nexus). However, when I close the emulator and try again I get the errors below:
PS C:\Users\4chea\pexhouseV2> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1197 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Launching emulator...
error Failed to launch emulator. Reason: Emulator exited before boot..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
> Task :app:installDebug FAILED
Skipping device 'emulator-5554' (emulator-5554): Device is OFFLINE.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
160 actionable tasks: 2 executed, 158 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No online devices found.
* 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 24s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
My emulator is open while this happens and says "failed to connect to metro server"
This here tells you the problem.
info Launching emulator...
error Failed to launch emulator. Reason: Emulator exited before boot..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
Something is wrong with your emulator. Try rebooting your system. If that doesn't work, try making a new emulator and see if that one works better. Also, I would turn off the Quickstart feature on your emulator - it may ask you as you shut it down if you want to save its memory state for faster boot times. I've had issues with that in the past similar to this.
Let me know if that changes anything. Good luck.
Related
when I use this command in the terminal:
PS C:\web dev\practice-projects\react-native\myproject> react-native run-android --no-jetifier
I get this whole error:
info JS server already running.
'adb' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
error
Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
> Task :app:compileDebugJavaWithJavac FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warning
14 actionable tasks: 2 executed, 12 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_271 contains a valid JDK installation.
* 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 39s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
My emulator isn't being launched and I have tried multiple fixes. I am getting started in react-native and don't understand the warnings or answers on similar questions. Please help.
There are few ways you can run your app,
Always works - Open the app from android studio. Select Open existing project and select android folder in your app to open the project and run from there after indexing is done.
Not sure would work and not recommended (might need release build) but you can drag your apk file that is auto generated to your simulator to install.
Add this line to gradle.properties file i.e. android/gradle.properties.
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home. replace the jdk version name or directory if required.
Note for mac - this is not library folder within your user directory so search them in your main drive location - should be something like machintosh hd
For windows - just replace the path after org.gradle.java.home=. Should be something like C:\\Program Files\\Java\\jdk1.8.0_144
In my case it was because the JAVA_HOME path could not find it.
Close all terminals and open a new one
Find a directory like this on your Mac:
/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
What may change is the version, but once you have it, it runs in that
path:
export JAVA_HOME = / Library / Java / JavaVirtualMachines /
jdk1.8.0_91.jdk / Contents / Home
IN MY CASE I RUN THIS COMMAND AT THE ROOT OF THE REACT NATIVE PROJECT:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
AND IT WORKED.
I have installed all necessary SDK , Platform Tools . I've the emulator open and running, adb added in PATH. Still this error isn't letting me through.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Launching emulator...
/bin/sh: adb: command not found
info Installing the app...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose
FAILURE: Build failed with an exception.flag for more details.
* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/manndave/IdeaProjects/MyFirstReactNative/android/local.properties'.
* 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
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081```
Please run the following from terminal, inside the project folder
export ANDROID_HOME=/Users/{yourusername}/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
Then npm run android
In my case, I had running Metro Bundler from another project. Closing it is solved my issue.
I am installing React Native according to this website https://medium.com/#leonardobrunolima/react-native-tips-setting-up-your-development-environment-for-windows-d326635604ea, it's very useful until I run the command react-native run-android, this is the error I receive:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Launching emulator...
error Failed to launch emulator. Reason: Emulator exited before boot..
> Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
24 actionable tasks: 4 executed, 20 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
> Could not read path 'C:\JesusApp\android\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\x86_64'.
* 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 7s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
> Could not read path 'C:\JesusApp\android\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\x86_64'.
* 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 7s
at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (C:\JesusApp\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at process._tickCallback (internal/process/next_tick.js:68:7)
My node version is 10, and I am working on Windows, please help, thank you.
I succeeded by doing the following steps:
Open android studio > AVD Manager > Actions (click the bottom icon) > Select Cool Boot Now.
Check your config and environment setup with instructions here, be very careful with pathes set up. Check the $PATH from your IDE's terminal.
check in the AVD that a particular Android OS is selected and installed for a virtual device you use (in my case it was not, I had yellow warning exclaim sign in an "Actions" column in an AVD's devices list).
Have your Gradle updated to at least 6.6 in the
android/gradle/wrapper/gradle-wrapper.properties
On Ubuntu after run I had to "push" switch-on button on the virtual device.
Finally, I got it up and running both on Windows 10 and Ubuntu 20.04 LTS with Android 30.
This might be the insufficient space in your machine or AVD or the mismatch in the configurations.
So, do the following steps to resolve this issue.
Verify that the environment variables are set for SDK path and adb.
Clean the project by Build -> Clean Project
Clean AVD by Open android studio > AVD Manager > Actions (click the bottom icon) > Select Cool Boot Now.
First start the android emulator on Android Studio, then execute the react-native run-android. If it doesn´t work go to android studio and do "Build -> Clean Project"
For me running
adb kill-server
and
adb start-server
worked
I also runned killall 9 node before that but it was not enough. MacOS asks for saving last state before restart also Android emulator asks before quiting it. Maybe the problem happens because saving a bad state and trying to start from that bad state. Not sure but I suspect one of these.
In my case, I've to wipe data on the virtual device.
Android Studio -> AVD -> Actions (↓) -> Wipe Data
I faced similar problem when executing my react-native code on Android Physical device. I am not sure if my solution will help.
We all know that ADB requires authorization from an Android device in order to communicate with it. It’s only by allowing the USB debugging and validating the computer’s RSA key fingerprint that we let the ADB daemon connect to our phone and control it. This is a security feature.
My phone was connected with USB and on changing USB Configuration on device, my phone gave me another prompt "Allow USB debugging?" Image available for reference. I got solution on reallow USB debugging
I had the same problem, only check the developer options and enable the debug by usb, on the device
For me, the problem ended up being quite simple. Working in react-native, I was running the following command from the terminal 'npx react-native run-android' in VS CODE. Though the emulator would run fine when started from Android Studios, I received the above error when running from the terminal in VS Code.
Solution: Run VS Code as Administrator. (or your terminal in general)
worked for me - there is not enough space on disk, Check that there is enough space on disk(where is the emulator was installed).
In my case, cool boot and wipe data didn't work. I just uninstall the virtual device and reinstall it and then it works for me.
Worked for me - reload system or clean system/android cache ./android/avd
Deleting the file app\build\intermediates\signing_config\debug\out\signing-config.json worked for me.
I'm started to learn React Native, I'm using Linux (Distro Fedora 29), Java is already working and running, Android Studio has been instaled and configured (Following android studio documentation), my environment variables is exactly like:
export ANDROID_HOME=/home/ghost/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
When i run my project with "react-native run-android" i get the follow error:
[ghost#localhost mobile]$ react-native run-android
info JS server already running.
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...
> Task :app:installDebug FAILED
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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2s
26 actionable tasks: 1 executed, 25 up-to-date
error 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
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.
Searching I find some tips, then I tried to restart the adb, like:
adb kill-server && adb start-server
Even if I do that, running adb devices gives me nothing
[ghost#localhost mobile]$ adb devices
List of devices attached
Then i tried to run in android studio before (third image url), then it return me the logs:
16:56 Gradle sync started
16:56 Project setup started
16:56 Gradle sync finished in 3 s 620 ms (from cached state)
**16:56 Emulator: statvfs('/home/ghost/.android/avd/Pixel_2_API_28.avd/snapshots/default_boot/ram.img') failed: No such file or directory
16:56 Emulator: ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy
16:56 Emulator: qemu-system-x86_64: failed to initialize KVM: Device or resource busy
16:56 Emulator: Process finished with exit code 0**
**Images that can contain useful information
SDK Manager:
SDK Platforms that I have installed
SDK Tools that I have installed
AVD Manager:
Device
I have been trying to solve the problem for four days, reading the documentation itself, searching in forums, redoing the settings. But so far I have not been able to. thanks in advance
cd android && ./gradlew clean
If this command doesn't work,
you might check the permissions on android/gradlew
they should be 755 not 644
run chmod 755 android/gradlew inside your app root folder
then run react-native run-android
and it should work again.
refer link
Connect your phone to the computer using USB and enable android debugging.
What went wrong:
Execution failed for task ':app:installDebug'.
com.android.builder.testing.api.DeviceException: No connected devices!
(Your phone isn't connected properly to your pc .enable MTP mode on your android device).
this command [ghost#localhost mobile]$ adb devices
List of devices attached
should output something like this if your device is connected properly
adb devices
List of devices attached
192.168.1.75:5555 device
Thanks everyone for the answers, they made me very helpful! The problem that happened is because i was running vagrant at the same time i tried to start android emulator, i discovered that after running "vagrant halt" and trying to run android again, after running emulator became posssible run react-native project
First I'm a newbie in react-native. I start a React-native in Facebook official site react-native tutorial. When I follow the react-native android setup step by step, then I run this project When a show this message please Resolve this Error, and Suggest me. Please help me.
D:\Linux\IDE\All-Workspace\JavaScript-Workspace\React-Workshop\AwesomeProject>react-native run-android
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat install debug)...
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 6s
27 actionable tasks: 1 executed, 26 up-to-date
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
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.
Emulator frozen in same state even after reboot etc..?
Follow Steps:
Open Android Studio
Open Configure
Open AVD Manager
There should be an emulator which is causing the issue - (if not create a new emulator an test build).
Go to down arrow in Actions and Select Stop
Same again in Actions but this time select Cold Boot Now
This works for me whenever ive had issues with an emulator.