31

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

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++
  • 12
    Folder was in ~/Android/Sdk/emulator/lib64/libstdc++ for me. – Kevin Brotcke May 20 '17 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

  • 2
    the best solution – Vladimir Nov 4 '17 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. – Vincent Gerris Jan 2 '18 at 0:41
  • Worked for me on Kubuntu 18.04. Thank you very much! – Vanessa Deagan Apr 30 '18 at 21:45
18

Run emulator from terminal

emulator -use-system-libs -avd YOUR_VIRTUAL_DEVICE_NAME
  • 1
    Is there any way to make this the default, so I don't need to run it from a terminal? – karora Jun 17 '17 at 12:05
  • 1
    @karora see jasperagrante's answer – Altiano Gerung Jul 28 '17 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 '17 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.

  • Haha this is ridiculous! – Kenneth Worden Jan 23 '18 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. – 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.

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 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.