skmlcd skmlcd - 2 months ago 50
Android Question

Android Studio AVD Linux AMDGPU driver

I'm unable to start any virtual device via AVD (Android Virtual Device Manager) on Linux using the newest open source AMD drivers AMDGPU.


  • GPU: AMD Rx 460

  • CPU: Intel Core i5-4460 CPU @ 3.20GHz × 4

  • OS: Solus OS

  • Kernel: 4.7.4

  • Mesa: 12.0.3

  • AMDGPU: 1.1.1



Error message:

Cannot launch AVD in emulator.
Output:
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: 153 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 49
Current serial number in output stream: 48
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: 153 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 49
Current serial number in output stream: 48
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: 153 (GLX)
Minor opcode of failed request: 24 (X_GLXCreateNewContext)
Value in failed request: 0x0
Serial number of failed request: 33
Current serial number in output stream: 34
QObject::~QObject: Timers cannot be stopped from another thread


The error message in screenshot form: avd amdgpu error

I assume that the problem is that it wants old open source drivers called RadeonSI, but my graphic card doesn't use that anymore, it uses newer AMDGPU.

Any tips how would I solve this problem?

Answer

I'm sorry I was wrong. It wasn't AMDGPU issue.

It was previously know issue with AVD bundled libraries.

~/Android/Sdk/tools/emulator -avd Nexus_5_API_23 -use-system-libs

Explanation

~/Android/Sdk/tools/emulator is the path to your SDK. You can find that inside Android Studio: File -> Settings -> Appearance & Behavior -> System Settings -> Android SDK

Nexus_5_API_23 is your virtual device that you have to create in Android Studio. You can find the list of available devices:

~/Android/Sdk/tools/emulator -avd -list-avds

And last: -use-system-libs uses your system libraries instead of bundled


The above is temporary solution. The permanent solution that I have found is a probably not that great. So use this at your own risk.

In your home directory .bashrc (hidden file) set environment variable:

export ANDROID_HOME=/path/to/your/android/sdk

Restart / logout.

cd $ANDROID_HOME/tools/lib64/libstdc++
mv libstdc++.so.6 libstdc++.so.6.bak
ln -s /usr/lib64/libstdc++.so.6 $ANDROID_HOME/tools/lib64/libstdc++

Obviously make sure that $ANDROID_HOME/tools/lib64/libstdc++ is the valid path. This will depend on where you extract/move your sdk directory.

After this everything was working for me.

There is another solution which looks more legit, but sadly did not work for me.

export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1

Issue on Google Bug Tracker