Android Studio AVD error launching

后端 未结 7 1054
感动是毒
感动是毒 2020-12-08 20:57

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

相关标签:
7条回答
  • 2020-12-08 21:08

    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.

    0 讨论(0)
  • 2020-12-08 21:14

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

    0 讨论(0)
  • 2020-12-08 21:23

    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
    
    0 讨论(0)
  • 2020-12-08 21:23

    I had exactly the same problem on Ubuntu 16.04 LTS and Android Studio 2.3.2 and I solved the issue by doing the following in a terminal window: (NOTE: I saw this somewhere else on online but I can't remember where so I can't give credit where credit is due)

    sudo apt list "*nvidia-[0-9][0-9][0-9]"
    

    mine returned: nividia-346 nividia-352 nividia-361 nividia-367 nividia-375

    I then ran the following for each that was returned:

    sudo apt install nvidia-375
    sudo apt install nvidia-367
    sudo apt install nvidia-361
    sudo apt install nvidia-352
    sudo apt install nvidia-346
    

    Then reboot Ubuntu and everything worked fine.

    0 讨论(0)
  • 2020-12-08 21:25

    Entering the following in the terminal (Ctrl-Alt-T) solved this for me:

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

    This apparently creates a symlink. This solution was taken from Line #23 of https://code.google.com/p/android/issues/detail?id=197254#c23.

    You may need to change the paths to the files depending on your installation (i.e. the original used the path ANDROID_HOME/android-sdk-linux_x86/ whereas my installation was just Android/Sdk/).

    0 讨论(0)
  • 2020-12-08 21:33

    On Debian Stretch (Android Studio 3.0.1 / Android Emulator 27.1.12) I experienced this same issue and applied the following fix:

    sudo apt-get install libstdc++6:amd64
    cd ~/Android/Sdk/emulator/lib64/libstdc++
    mkdir old
    mv libstdc* old
    ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    
    0 讨论(0)
提交回复
热议问题