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

后端 未结 3 954
自闭症患者
自闭症患者 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 ;)

    0 讨论(0)
  • 2021-02-14 08:58

    Thanks to @Dawid Drozd's answer, I've created a Windows batch script that will run AVD without sound input/output. Just give the script a parameter of AVD name.

    The trick is to run set QEMU_AUDIO_DRV=none before executing AVD.

    @echo off
    if "%1"=="" goto usage
    set QEMU_AUDIO_DRV=none
    @echo Running AVD "%1" without sound...
    @echo.
    %ANDROID_HOME%\tools\emulator.exe -avd %1
    goto :eof
    
    :usage
    @echo.
    @echo -----------------------------------
    @echo Usage: %0 ^<avd-name^>
    @echo -----------------------------------
    @echo.
    @timeout 3 >0
    exit /B 1
    
    0 讨论(0)
  • 2021-02-14 08:58

    Here's my take on it:

    $ cd /opt/android-sdk/emulator 
    $ mv emulator{,.orig}
    $ cat <<EOF > emulator
    heredoc> #!/bin/sh
    heredoc> 
    heredoc> QEMU_AUDIO_DRV=none `dirname $0`/emulator.orig "$@"
    heredoc> EOF
    $ chmod +x emulator
    
    0 讨论(0)
提交回复
热议问题