How to solve Android Studio Emulator: libGL error on Ubuntu systems

Android Studio 3.1, the official IDE for Android development, provides the fastest tools for building apps for every type of Android device. It gives you world-class code editing, debugging, performance tooling, a flexible build system, and an instant build/deploy system all allow you to focus on building unique and high-quality apps.

 

How to solve Android Studio Emulator: libGL error on Ubuntu systems
How to solve Android Studio Emulator: libGL error on Ubuntu systems

Android Studio 3.1 has some issues with Ubuntu 17.10 and 18.04

I recently upgraded my Android development machine from Ubuntu 16.04 LTS, where Android Studio was working totally fine, to Ubuntu 18.04 LTS. The system runs smooth and the new ambient with the community theme is amazing, but on trying to run Android emulators from Android Studio 3.1 I got some issues.

This is the error log I got:
08:24 Emulator: Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
08:25 Emulator: libGL error: unable to load driver: i965_dri.so
08:25 Emulator: libGL error: driver pointer missing
08:25 Emulator: libGL error: failed to load driver: i965
08:25 Emulator: libGL error: unable to load driver: swrast_dri.so
08:25 Emulator: libGL error: failed to load driver: swrast

I made a quick search on the Internet and I found different solutions to this problems but, unfortunately, no one is working in my case.

Looking at Google official documentation, the suggested solution is to edit the file  ~/.profile adding to it the environment variable ANDROID_EMULATOR_USE_SYSTEM_LIBS=1.

Still, it not works for me.

I started to make some trials and finally, I managed a working solution.
$ cd ~/Development/Android/Sdk/emulator/lib64/
$ mv libstdc++ libstdc++.bak

Another possible solution as suggested by user in comments is the following. Editing ~/.profile doesn’t work sometimes because the file was not read from the system before the run of Android Studio instance.

In this case, try running studio.sh with this command:
ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 ./studio.sh

And it’s done.

Useful links and references

Android Studio 3.1 and above – https://developer.android.com/studio/index.html

Android Studio – Environment Variables – https://developer.android.com/studio/command-line/variables.html

Android Studio buggy after upgrade to 16.10 – https://askubuntu.com/questions/867081/android-studio-buggy-after-upgrade-to-16-10/

Android Studio – libGL error and libstdc++: Cannot launch AVD in emulator –  https://issuetracker.google.com/issues/37075150

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *