Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I start Android Emulator, the audio on my Mac desktop stops

When I start Android Emulator, the audio on my Mac desktop stops. It starts again when I close the emulator.

like image 813
Ivo Stoyanov Avatar asked Apr 08 '21 08:04

Ivo Stoyanov


Video Answer


2 Answers

I found easier way than accepted answer from @Ivo Stoyanov to solve this. Just open the emulator config file (for my mac it's /Users/{myname}/.android/avd/{emulator_name}/config.ini and set

hw.audioInput=no
hw.audioOutput=no

Screen from visual studio code

If it's not working then you should "Wipe Data" and "Cold Boot Now" in Android Virtual Device Manager screen from android virtual device manager

like image 80
Paweł Kanarek Avatar answered Oct 04 '22 04:10

Paweł Kanarek


When the emulator is started with enabled audio, sometimes it overrides the audio channel of the Mac machine. This happens even if you disable access to the microphone for Android studio in Security settings. To fix the issue you should start the emulator with disabled audio.

There are two options to start the emulator with disabled audio:

I. Start the emulator from the console:

emulator -avd Pixel_2_API_27 -qemu -no-audio

II. If you want to start the emulator with disabled audio directly from Android studio, you should replace the emulator file with a script that will run emulator with additional parameters:

Android Studio by default uses the binary $ANDROID_SDK/emulator/emulatorwhich is located in: ~/Library/Android/sdk/emulator/

You have to do the following:

  1. Rename the emulator binary to emulator-original.

  2. Create a bash script text file with the name emulator that contains:

#!/bin/bash    
~/Library/Android/sdk/emulator/emulator-original $@ -qemu -no-audio
  1. Set the newly created script permissions with chmod +x emulator

Now, Android Studio will run your script that will run the original binary with the addtitional parameters to disable emulator's audio.

N.B. Kudos for the script solution to MartinCR who proposed it here.

like image 40
Ivo Stoyanov Avatar answered Oct 04 '22 03:10

Ivo Stoyanov