Monday, May 29, 2017

AVD emulator mysteriously packed up on ubuntu?

Your Android emulator mysteriously decides to give up for no apparent reason... The Android Studio UI won't tell you anything about why (I guess that interrupts the "experience" of tearing your hair out).

Run it from the command line:

$ ~/Android/Sdk/emulator/emulator -avd Nexus_S_API_21 -gpu mesa

Where Nexus_S_API_21 is the name of the avd we want to run. Those can be listed using the -list-avds argument. The -gpu-mesa argument tells the emulator to use software rendering: which is somewhat slower but supposedly reliable.

If you then see:
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 24 (X_GLXCreateNewContext)
Value in failed request: 0x0
Serial number of failed request: 39
Current serial number in output stream: 40
QObject::~QObject: Timers cannot be stopped from another thread
Segmentation fault (core dumped)

Then apparently we need to use the libstdc++6 from the system : not the one Android helpfully supplied.
$ sudo apt-get install lib64stdc++6
$ cd ~/Android/Sdk/emulator/lib64/libstdc++
$ mv libstdc++.so.6 libstdc++.so.6.original
$ ln -s /usr/lib64/libstdc++.so.6 ~/Android/Sdk/tools/lib64/libstdc++

All based on this article here - just slightly modified the paths to reflect Android's current directory structure.

No comments:

Post a Comment