6

I used to launch and debug Android Studio apps on emulator without problems. However, recently I am constantly failing to start the emulator. Updating the SDK and system images did not solve the problem. Updating qemu-system-* did not help either.

System info: Linux Fedora 25 (x86_64), Android Studio 2.2.3

Mehdi Haghgoo
  • 3,144
  • 7
  • 46
  • 91

8 Answers8

17

It turned out that the problem was due to the same old NVidia driver problems with Linux. To fix the crash, I opened AVD Manager from Android Studio (Tools->Android->AVD Manager), and then opened the virtual device settings. Then in the Emulated Performance section, next to Graphics, I selected Software rather than Automatic or Hardware. This does the trick and no more crashes occur for the emulator, though it seems considerably slower, than it used to be when Emulated Performance presumably used Hardware by default. The following screenshots will hopefully give a better hint on the solution.
enter image description here

enter image description here

Mehdi Haghgoo
  • 3,144
  • 7
  • 46
  • 91
  • 2
    It works, but the emulator gets slow, too slow. I wish nVidia provided decent drivers for Linux. I almost regret installing them... – Vitor Hugo Schwaab May 30 '17 at 00:53
  • 1
    Yeah that's true Vitor. I sometimes use real phone for debugging. It turns out Intel graphics are the best friends for Linux. – Mehdi Haghgoo May 30 '17 at 02:19
  • 1
    I use real phone most of the time, but one of my current projects require multi-phone communication. A chat between users, specifically. Turns out I need more than one phone to chat with myself when debugging... =/ – Vitor Hugo Schwaab May 31 '17 at 11:49
  • @VitorHugoSchwaab in that case you will need several emulators i guess and huge amount of ram and patience. – Mehdi Haghgoo May 31 '17 at 11:58
2

Have you tried running AVD Manager from a terminal?

Control the Emulator from the Command Line

Here you will probably have more details of the errors that make the emulator not work fine.

2

Delete in your Android SDK the directory "libstdc++" in the directory "emulator/lib64". The emulator will use the system libraries now.

Roger
  • 21
  • 1
2

Sometimes killing the qemu process and then relaunching AVD solves the problem.

killall qemu-system-x86_64
Mohsents
  • 691
  • 11
  • 9
1

I was fiddling around on an issue like this on Fedora 32 for a couple of days.

I had to to make system unload the free nouveau graphics driver and install/load the non free nvidia driver.

Very useful:

https://rpmfusion.org/Howto/NVIDIA

To check which driver is loaded I used:

lshw -c video

It is difficult to grab the correct rpm package from rpmfusion.

If nvidia is not loaded, then you can check:

more /var/log/messages | grep nvidia

It told me which driver series to use.

After successful install of nvidia driver, I can use HW graphics option in AVD manager.

Matthias
  • 11
  • 1
  • Does the free nvidia driver work well with nvidia cards? I had my frustrations with it years ago. Then moved to intel graphics completely. – Mehdi Haghgoo Jun 15 '20 at 15:46
1

I know this is an old thread but the answer that helped me is not in this page:

The problem was that my mother board had the parameter "CPU virtualization" disabled. After I turned it on, the emulator started working.

Xavier Vega
  • 701
  • 5
  • 6
1

I had this problem and I discovered that I did not have enough memory to run my avds. To check this, it is best to try run the avds through the terminal: First: Check the avds you have installed by changing directory (cd) to the tools folder under the Sdk folder in the Android folder:

//to cd to the tools directory from your home: cd Android cd Sdk cd tools

Once in the tools folder, check the avds installed: $ ./emulator -list-avds

To launch an emulator listed under your installed emulators:

$ ./emulator @complete_name_of_avd

If you have enough memory, you should be able to start your started avd successfully. If not due to memory issues, you will get the information through your terminal. Free up enough memory from your device to ensure you are able to run the avd successfully.

Also, you might want to reconsider testing an app from the virtual emulator as it drags the machine so much. A physical device connected via USB will be much better to use. just ensure that you have enabled debugging on that particular device and you will be able to identify it among the list of options you have for deploying your application.

D.Machanje
  • 11
  • 1
1

None of above helped me. For versions 2021.* and 2022.* just disable ipv6. I have no idea what if you really need ipv6 but only this action solved the problem for me. Check your Linux distro manuals for details how to disable ipv6.

Almaz
  • 920
  • 11
  • 13