Android emulator fails to start after an update

The problem:

A week ago, after some update(not really sure which one), I faced a very frustrating issue: I could not start my android emulator(AVD) anymore. It failed with a not very informative error:

Android/Sdk/tools/emulator -netdelay none -netspeed full -avd Nexus_5_API_23
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  49
  Current serial number in output stream:  48
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  49
  Current serial number in output stream:  48
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  33
  Current serial number in output stream:  34
QObject::~QObject: Timers cannot be stopped from another thread

I say that it is not very  informative because it talks about glx and dri, while the actual problem is with libstdc++.so.6 which provided with the Android SDK. So in order to make the Android Emulator work again, we will have tor replace it with the system default libstdc++.so.6

The solution( fixing android emulator)

This fix android emulator assumes that you have android sdk installed at ~/Android/Sdk . This is the default path when installing Android Studio on Linux. If you have it under different directory please replace ~/Android/Sdk with the path to your sdk in the first line.

cd ~/Android/Sdk/tools/lib64/libstdc++/
mv libstdc++.so.6 libstdc++.so.6.bak
ln -s /usr/lib64/libstdc++.so.6

And that is all, folks. Android Emulator should start properly.

Update 1:

for newer versions of android sdk libstdc was moved inside the emulator folder, so updated path goes like this:

cd ~/Android/Sdk/emulator/lib/libstdc++/
mv libstdc++.so.6 libstdc++.so.6.bak
ln -s /usr/lib64/libstdc++.so.6

Update 2:

If you cannot see libstdc++.so.6 in any of above paths, just make a search for it in your android sdk folder and adjust the path accordingly.

Disclaimer: based on tobias.preuss answer.

comments powered by Disqus