Search code examples
androidmacosandroid-studioandroid-emulator

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.


Solution

  • 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.