Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

  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 and output). I'm using Android SDK which has verion of Android Tools 25.2.2). In older AVD manager, i recall that option to completely disable audio on AVD was present.
  2. When I want to create a batch script, to run with -noaudio option, as mentioned in the Google's official Control the Emulator from the Command Line page, I'm running the command as emulator.exe -avd Nexus_4 -noaudio, but it throws error

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

  1. Android Emulator dialog opens, with indeterminate progress bar, and the AVD doesn't start at all. Keeps loading forever.

Any help is appreciated.

like image 590
tekk Avatar asked Oct 26 '16 22:10

tekk


2 Answers

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 ;)

like image 135
Dawid Avatar answered Oct 01 '22 18:10

Dawid


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
like image 43
tekk Avatar answered Oct 01 '22 20:10

tekk