Android Emulator does not Launch in Ubuntu 16.10

A couple of days ago, I updated Android Studio to the latest version. Then, I tried to run the emulator to test an app I'm working on.

~/Android/Sdk/tools$ ./emulator -avd Nexus_5X_API_25

And I got this:

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
...

Oops... What happened? It turns out there's an open issue with the version of libstdc++ currently provided with Android Studio. Thankfully, it's trivial to fix. Just create a symbolic link to the version of the library shipped with Ubuntu.

$ cd ~/Android/Sdk/emulator/lib64/libstdc++
$ mv libstdc++.so.6 libstdc++.so.6.bak
$ ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6

That's it!

Note that file paths may be different in your case, so you might have to look around a bit to find where libstdc++.so.6 is located in your system and Android SDK.