Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio AVD error launching

Tags:

I have a Nexus 6P API23 emulator downloaded on my Ubuntu 15.10 PC. When I try to launch it, it fails and a dialog box pops up and says:

(AVD config: Nexus 6P API 23 x86 -- Hardware-GLES 2.0 Graphics)

Cannot launch AVD in emulator.
Output:
libGL error: unable to load driver: nouveau_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: nouveau
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:  47
  Current serial number in output stream:  46
libGL error: unable to load driver: nouveau_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: nouveau
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:  47
  Current serial number in output stream:  46
libGL error: unable to load driver: nouveau_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: nouveau
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:  33
  Current serial number in output stream:  34
QObject::~QObject: Timers cannot be stopped from another thread

I have tried other AVDs and they don't work.

like image 681
Kevin Dixson Avatar asked Mar 23 '16 21:03

Kevin Dixson


People also ask

Why is my AVD not working?

In case you get an error like "Intel virtualization technology (vt,vt-x) is not enabled". Go to your BIOS settings and enable Hardware Virtualization. 3) Restart Android Studio and then try to start the AVD again.

Why AVD Manager is not working?

SDK Build Tools are not installed If it fails then you may have to install it again. You look at the build tab at the bottom of the screen, it will display the error message and option to install the Build tools. Install it and you should be able to see the AVD Manager. Another way is to go to the SDK Manager.

How much RAM do you need for AVD?

o Depending on your computer specs, the recommended ram size is in the range between 512 MB – 1024 MB. Although you can give more ram to the emulator but an actual android device would normally have 512 MB – 1024 MB for ram only.


3 Answers

you can also use "Software" in the Emulated Performance Graphics option, in the AVD settings

like image 136
aoliva Avatar answered Sep 24 '22 05:09

aoliva


I've had the same error as you and have managed to find a workaround. Hopefully this will solve your issue as well.

Rather than launching the emulator from Android Studio, open the terminal and cd into the tools directory withing your Android SDK directory - mine is ~/Android/Sdk/tools. From there run the command:

LD_PRELOAD='/usr/$LIB/libstdc++.so.6' DISPLAY=:0 ./emulator -avd <insert avd name here>

You should now be able to launch your application with android studio by pressing the green run arrow and selecting the emulator you just started.

For more information as to why this works go here

Edit:

After some more thought, I tried this script and it seems to work, so that you can start the emulator within the Android Studio. It replaces emulator executable with a bash script that calls it as above. You'll need to change to tools path to the correct location. I'd also suggest making a backup copy of your tools directory in case something goes wrong:

#!/bin/bash

TOOLS_PATH='/home/user/Android/Sdk/tools'
UNEXPANDED_LIB='$LIB'

for emul in ${TOOLS_PATH}/em*
do
cp ${emul} ${emul}-orig
cat <<EOF > ${emul}
#!/bin/bash
LD_PRELOAD='/usr/$UNEXPANDED_LIB/libstdc++.so.6' ${emul}-orig "\$@"
EOF
done
like image 29
sapensadler Avatar answered Sep 27 '22 05:09

sapensadler


My case: I work with Debian Jessie and Android Studio 2.2.3. My graphic card is an ATI Radeon HD 6850 by Sapphire.

The emulator says that there is a problem loading the graphic driver ("libGL error: unable to load driver: r600_dri.so"). As it is explained here, it seems that Google packaged with Android Studio an old version of one library (libstdc++.so.6), and the emulator fails when it tries to use the graphic card.

Solution? Very easy: to use the system libraries instead of the packaged in Android Studio. How? Adding "-use-system-libs" at the end of the command. So:

./emulator -avd EMULATOR_NAME -netspeed full -netdelay none -use-system-libs

The definitive solution (if you don't want to use the terminal) is to set the ANDROID_EMULATOR_USE_SYSTEM_LIBS environment variable to 1 for your user/system. With this change, when you run the emulator within Android Studio, it will also load the system libraries instead of the packaged.

PS - The easiest way I found to set the environment variable, it's to modify the script that launch the Android Studio (studio.sh, in my case it is inside /opt/android-stuido/bin), and add at the begining this:

export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1

UPDATE December 2017: I had the same problem with Debian Stretch and Android Studio 3.0.1 (same graphic card). The same solution works for me.

like image 7
Pablo Insua Avatar answered Sep 27 '22 05:09

Pablo Insua