android emulator always giving error emu-crash-xx-xx.db and quit before it finished opening

1.3k Views Asked by At

I have completed new setup in windows for react native : whenever I am trying to start the emulator from command I am getting this issue , but I can open emulator inside android studio without any problem

> react-native run-android

* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
error Failed to launch emulator. Reason: The emulator (INFO    | Storing crashdata in: C:\Users\arunk\AppData\Local\Temp\\AndroidEmulator\emu-crash-34.1.18.db, detection is enabled for process: 13500) quit before it finished opening. You can try starting the emulator manually from the terminal with: C:\Users\arunk\AppData\Local\Android\Sdk/emulator/emulator @INFO    | Storing crashdata in: C:\Users\arunk\AppData\Local\Temp\\AndroidEmulator\emu-crash-34.1.18.db, detection is enabled for process: 13500.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
BUILD FAILED in 19s
error Failed to install the app. Command failed with exit code 1: gradlew.bat 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 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 19s.

raised issue on github too text

I am trying to run android emulator usign

npm run android 

or

npx react-native run-android

expected : after metro start android emulator should start automatically but it is failing everytime and giving this emu-crash.db logs issue

trying to delete that log file too tried to run different version of react native too

4

There are 4 best solutions below

1
UnableHead On BEST ANSWER

I have the same problem.

This bug came from the command line emulator -list-avds

Now this command line add a new log at the first line :

INFO    | Storing crashdata in: /tmp/android-xxx/emu-crash-34.1.18.db, detection is enabled for process: 20206
.Pixel_2_API_31
2.7_QVGA_API_31
3.2_QVGA_ADP2_API_31
3.7_WVGA_Nexus_One_API_31
6.7_Horizontal_Fold-in_API_31
Pixel_2_API_29
Pixel_2_API_33
Pixel_XL_API_31

The problem is that react-native take always the first emulator in this list as default emulator to launch. But now it try to open INFO | Storing crashdata in: /tmp/android-matthias/emu-crash-34.1.18.db, detection is enabled for process: 20206 that is not a emulator name, but just a log info.

To launch the emulator, until a fix, you can still use the command line

emulator @name_of_device

then use the common command :

npm run android 
3
Sally Azulay On

First of all. do you run it only from VSCode or you do it from Android Studio too?

Try to run it from android studio and see if you get the same error. Also, try to run emulator and then run the command from you package.json.

you can also try the following node command

"android": "lsof -ti :8081 | xargs kill -9 && rm -rf node_modules && rm -f package-lock.json && npm i --legacy-peer-deps && cd android && ./gradlew clean && cd .. && react-native start --reset-cache"

The command will kill the port 8081, removes node_modules and package-lock.json. after it will install all the dependencies again and cd to android folder and clean the gradle folder. finally runing the metro with --reset-cache flag.

Let me know if that helps.

1
Beulah Evanjalin On

Launching emulator... error Failed to launch emulator. Reason: The emulator quit before it finished opening. Crash data stored in: /tmp/android-beulah/emu-crash-34.1.18.db, with detection enabled for process: 97555. warn Please launch an emulator manually or connect a device. Otherwise, the app may fail to launch.

I also got a similar error earlier today. Then i realized that it was attempting to use Android Emulator Info as an AVD device.

After trying a few things, I tried starting the emulator myself using emulator @Pixel_6_Pro_API_33 and it actually worked!

It looks like there's a glitch with how the emulator starts up automatically. If you're having the same issue, you can try starting your emulator manually. Just make sure to replace Pixel_6_Pro_API_33 with the name of your own AVD.

Run emulator -list-avds, you get a list of the names of all the AVDs you have set up.

0
Marcus Fonseca On

The issue for me stemmed from the incompatibility between React Native version 0.72 and Android 14. React Native began supporting Android 14 from version 0.73 onwards. Once I updated, everything worked smoothly.