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
2
  • is android studio on this path opt/android-studio?? Jan 2, 2017 at 13:15
  • This happens for me on Ubuntu 17.04 also. @Arduino_Sentinel's answer fixed it.
    – Rimian
    Jul 10, 2017 at 20:32

7 Answers 7

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++
1
  • 12
    Folder was in ~/Android/Sdk/emulator/lib64/libstdc++ for me. May 20, 2017 at 6:41
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

3
  • 2
    the best solution
    – Vladimir
    Nov 4, 2017 at 19:45
  • This didn't work on Ubuntu 17.10 with Android Studio 3.01. I just renamed the library folder ~/Android/Sdk/emulator/lib64/lib/libstdc++ and it worked. Jan 2, 2018 at 0:41
  • Worked for me on Kubuntu 18.04. Thank you very much! Apr 30, 2018 at 21:45
18

Run emulator from terminal

emulator -use-system-libs -avd YOUR_VIRTUAL_DEVICE_NAME
3
  • 1
    Is there any way to make this the default, so I don't need to run it from a terminal?
    – karora
    Jun 17, 2017 at 12:05
  • 1
    @karora see jasperagrante's answer Jul 28, 2017 at 0:46
  • @AltianoGerung yeah, since I already wrap Android Studio in a shell script I ended up setting the variable in there...
    – karora
    Aug 5, 2017 at 11:28
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.

2
  • Haha this is ridiculous! Jan 23, 2018 at 2: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. Jan 26, 2018 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.

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 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .