Android studio AVD issue with Ubuntu is really annoying because Android Studio environment has a lot of built-in parts and one of the most useful is Android Virtual Device Emulator.
Android Studio rants unable to load driver and AVD doesn’t start
Android Virtual Device Emulator helps you to test your applications in an easy way and without using a real device. The latest revision of Android Studio has also a very performant emulator system and you don’t feel the need of special Android emulator like Genymotion.
While using it on Fedora is a very charming experience, on different systems with Ubuntu 16.10, Ubuntu 17.04, Ubuntu 17.10 and Ubuntu 18.04 on board many issues came up.
Nothing painful, but if you get:
Cannot launch AVD in emulator. Output: libGL error: unable to load driver: i965_dri.so libGL error: driver pointer missing
or something similar, you’re unable to work with the Android Emulator Device.
It’s a libGL error and libstdc++ issue. Cannot launch AVD emulators
It’s a known bug and you can easily beat it with some simple steps.
I have tested this solution on an Ubuntu 16.10 and Ubuntu 17.04 64bit
First, install some packages and libs:
$ sudo apt-get install lib64stdc++6:i386 $ sudo apt-get install mesa-utils
Second, tweak some links:
$ cd YOURPATH/Android/Sdk/tools/lib64 $ mv libstdc++/ libstdc++.bak $ ln -s /usr/lib64/libstdc++.so.6 libstdc++
Sidenote: as many users have reported in the comments, in a recent version like Ubuntu 17.10/18.04 or in a different system like KDE Neon, the correct path is YOURPATH/Android/Sdk/emulator/lib64.
I have tested the following solution on an Ubuntu 17.10 and Ubuntu 18.04 64bit
So, the corrected and update instructions are:
$ cd YOURPATH/Android/Sdk/emulator/lib64 $ mv libstdc++/ libstdc++.bak $ ln -s /usr/lib64/libstdc++.so.6 libstdc++
Third, relaunch your AVD device and test it.
If you experimented another issue, especially with Android Studio 3.1, on Ubuntu system like the new one Ubuntu 18.04 LTS, maybe you can also find useful the newer article How to solve Android Studio Emulator: libGL error on Ubuntu systems.
An alternative solution, available only by the terminal is to launch the emulator with:
$ emulator -use-system-libs -avd YOUR_VIRTUAL_DEVICE_NAME
That’s all. Enjoy it!