运行 Android 带有 -noaudio 选项的模拟器 returns "qemu-system-i386.exe: -audio: invalid option"

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

  1. 我是 运行ning Windows 10、64 位,Android Studio 2.2.2。从 Android SDK 的 AVD 管理器创建 AVD 时,我没有看到完全禁用音频(输入和输出)的选项。我正在使用 Android SDK,其版本为 Android Tools 25.2.2)。在旧的 AVD 管理器中,我记得存在完全禁用 AVD 音频的选项。
  2. 当我想创建批处理脚本时,运行 带有 -noaudio 选项,如 Google 的官方 Control the Emulator from the Command Line 页面所述,我运行将命令设置为 emulator.exe -avd Nexus_4 -noaudio,但会抛出错误

qemu-system-i386.exe: -audio: invalid option

  1. Android 模拟器对话框打开,进度条不确定,AVD 根本没有启动。永远保持加载。

感谢任何帮助。

我已经在 Linux 上测试过了。 (对于 windows 结帐评论或@Tekk 回答)
如果您不想要音频,只需使用:

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.

解法:

Post about emulated audio devices

在 linux 如果我想要声音我使用:

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

它工作正常。我也没有 100% CPU 使用率

My snippet:

#!/bin/bash
# 
# 

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

只需将 Android-sdk/tools/emulator 替换为 Android-sdk/tools/emulator.orig 然后在 Android-sdk/tools/emulator(允许执行)中使用上述源代码创建脚本。

请记住,有时 android SDK 升级时会删除此脚本 ;)

感谢@Dawid Drozd 的回答,我创建了一个 Windows 批处理脚本,它将 运行 无声 AVD input/output。给脚本一个AVD名称的参数即可。

诀窍是在执行AVD之前运行set QEMU_AUDIO_DRV=none

@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

这是我的看法:

$ cd /opt/android-sdk/emulator 
$ mv emulator{,.orig}
$ cat <<EOF > emulator
heredoc> #!/bin/sh
heredoc> 
heredoc> QEMU_AUDIO_DRV=none `dirname [=10=]`/emulator.orig "$@"
heredoc> EOF
$ chmod +x emulator