Android studio on Arch Linux libGL error

(Tutorials)

After installing Android Studio on Arch Linux when attempting to launch an emulator I was met with a rather cryptic and lengthy error message:

libGL error: unable to load driver: radeonsi_dri.so
 libGL error: driver pointer missing
 libGL error: failed to load driver: radeonsi
 libGL error: unable to load driver: radeonsi_dri.so
 libGL error: driver pointer missing
 libGL error: failed to load driver: radeonsi
 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: radeonsi_dri.so
 libGL error: driver pointer missing
 libGL error: failed to load driver: radeonsi
 libGL error: unable to load driver: radeonsi_dri.so
 libGL error: driver pointer missing
 libGL error: failed to load driver: radeonsi
 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: radeonsi_dri.so
 libGL error: driver pointer missing
 libGL error: failed to load driver: radeonsi
 libGL error: unable to load driver: radeonsi_dri.so
 libGL error: driver pointer missing
 libGL error: failed to load driver: radeonsi
 libGL error: unable to load driver: swrast_dri.so
 libGL error: failed to load driver: swrast
 X Error of failed request:  BadValue (integer parameter out of range for operation)
 Major opcode of failed request:  155 (GLX)
 Minor opcode of failed request:  24 (X_GLXCreateNewContext)
 Value in failed request:  0x0
 Serial number of failed request:  39
 Current serial number in output stream:  40
 QObject::~QObject: Timers cannot be stopped from another thread

The error relates to libstdc++.so.  Appearantly Android SDK comes with its own version of this library which doesn’t work.  As such the solution is to use the one provided by Arch Linux.  The commands to solve this issue are really dead simple and for clarity’s sake I will iterate the fix process.

  1. Go to the folder containing libstdc++.so.6
  2. Rename libstdc++.so.6 to libstdc++.so.6.back
  3. Create a symlink to system library and name the link libstdc++.so.6

And the commands:

Depending on your setup the paths may not be the same but the core thing to take from this is: use system libstdc++.so.6 instead of Android SDK version.

Update 11.1.2017: Updating Android Studio (or at least android sdk) resets this change so the process needs to be repeated each time update is performed.