Running Android emulator with -noaudio option returns “qemu-system-i386.exe: -audio: invalid option”

后端 未结 3 968
自闭症患者
自闭症患者 2021-02-14 08:30
  1. I\'m running Windows 10, 64 bit, Android Studio 2.2.2. When creating an AVD from the Android SDK\'s AVD Manager, I don\'t see an option to completeley disable audio (input
3条回答
  •  情话喂你
    2021-02-14 08:54

    I have tested this on Linux. (For windows checkout comments or @Tekk answer)
    If you don't want audio simply use:

    export QEMU_AUDIO_DRV=none && emulator -avd Nexus_4
    

    TL;DR

    Quote from here

    Based on some digging around, it looks like QEMU2 removed the ability to completely disabled audio - you can specify which sound card the audio goes through, but can't turn it off altogether. The "-audio" flag was replaced with "-soundhw", which lets us specify which sound card to use.

    QEMU1 (using the "-engine classic" emulator command line flag) does work when "-noaudio" is passed), but passing "-soundhw none" to QEMU2 also fails.

    Solution:

    Post about emulated audio devices

    On linux if I want sound I use:

    export QEMU_AUDIO_DRV=pa && emulator.orig -avd Nexus_S_api_23
    

    It works fine. Also I don't have 100% CPU usage

    My snippet:

    #!/bin/bash
    # http://stackoverflow.com/a/35822173/1052261
    # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
    
    SOURCE="${BASH_SOURCE[0]}"
    while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
      DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
      SOURCE="$(readlink "$SOURCE")"
      [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
    done
    DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
    
    #echo "DIR is '$DIR'"
    #If you want audio pass QEMU_AUDIO_DRV=pa -> https://www.wagner.pp.ru/fossil/vws/wiki?name=QEMU+audio
    export QEMU_AUDIO_DRV=none && $DIR/emulator.orig -use-system-libs "$@" -qemu -m 512 -enable-kvm
    

    Simply replace Android-sdk/tools/emulator to Android-sdk/tools/emulator.orig Then create script with above source in Android-sdk/tools/emulator (Allow for execution).

    Remember sometimes when android sdk will upgrade it will remove this script ;)

提交回复
热议问题