32

I recently upgraded from 16.04 LTS where my android studio was working fine to 16.10 but on trying to run my avd emulators, this is the error log i get back instead

Cannot launch AVD in emulator.
Output:
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: 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:  155 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  55
  Current serial number in output stream:  54
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: 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:  155 (GLX)
  Minor opcode of failed r
Aaron Hill
  • 4,957

7 Answers7

48

In the recent android studio updates, google use a libstdc++ that is incompatible with the intel driver installed on the system

You first have to install the following packages if there not on the system lib64stdc++6 and mesa-utils

sudo apt-get install lib64stdc++6 mesa-utils

Then symlink the libraries to the android sdk tools path

## For the /Sdk/tools path

cd ~/Android/Sdk/tools/lib64/libstdc++
# making a copy of the file
sudo mv libstdc++.so.6 libstdc++.so.6.og
# symlink
sudo ln -s /usr/lib64/libstdc++.so.6 ~/Android/Sdk/tools/lib64/libstdc++

## For the /Sdk/emulator path

cd ~/Android/Sdk/emulator/lib64/libstdc++
# making a copy of the file
sudo mv libstdc++.so.6 libstdc++.so.6.og 
# symlink
sudo ln -s /usr/lib64/libstdc++.so.6 ~/Android/Sdk/emulator/lib64/libstdc++
42

I had also this problem on Ubuntu 17.04 and here's what I did.

Edit your .profile using your favorite text editor

atom ~/.profile

Append this at the end of the file

export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1

Source: Android SDK Environment Variable

18

Run emulator from terminal

emulator -use-system-libs -avd YOUR_VIRTUAL_DEVICE_NAME
katenzo
  • 181
4

another simple workaround is to rename the libstdc++ in the emulator folder in the Android sdk directory. It will fallback to the system libs (need to be installed). That 'just worked' for me on Ubuntu 17.10.

Vincent Gerris
  • 2,437
  • 1
  • 20
  • 14
  • Haha this is ridiculous! – Kenneth Worden Jan 23 '18 at 02:03
  • What do you mean :)? I personally don't understand why Google ships it like this. The use-system-libs option didn't work for me, so it seems like a valid workaround, one just has to do it again when the emulator is updated. – Vincent Gerris Jan 26 '18 at 13:41
2

Update the emulator.

Tools -> SDK Manager -> SDK Tools -> Android Emulator

enter image description here

This is a bug which is being fixed in 27.2.9.

The Linux version of the Android Emulator is now built using a modern Clang C++ toolchain. This change fixes the issue of the emulator failing to start due to libGL and libstdc++ errors.


FYI: BTW manually creating symlinks is not a good idea.

Setting ANDROID_EMULATOR_USE_SYSTEM_LIBS is a better approach. However, that's also not necessary when you could just update the emulator.

Gayan Weerakutti
  • 3,770
  • 26
  • 38
1

I switched the graphics acceleration from auto/hardware to software. The drivers that are causing this issue are only needed to use real hardware for graphics acceleration. Unless your working on a game or other graphics intensive software you don't really need this. This has to be done on each adv but stays set once done.

-1

This link help. I did modify the location of the libstdc++.so based on my Ubuntu 17.10 installation. The libstdc++.so file location was different. Search your computer for libstdc++.so

Ubuntu 17.10 and Android Studio 3.1

cd /opt/android-sdk/emulator/lib64/libstdc++
mv libstdc++.so.6{,.bak}
mv libstdc++.so.6.0.19{,.bak}
ln -s /usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.so 
karel
  • 114,770