7

I am trying to decrease the ridiculous CPU usage of my Android emulator.

Thanks to this answer I found out that the CPU usage can be greatly decreased by disabling audio.

Solutions

I found out there are three ways to run the emulator without audio.

  1. As a command line flag:

    $ emulator -avd <name> -noaudio
    
  2. By editing ~/.android/<name>.avd/config.ini and replacing this line:

    hw.audioInput=yes
    

    with these two:

    hw.audioInput=no
    hw.audioOutput=no
    
  3. Instead of using the graphical AVD manager, use the following command to create an emulator:

    $ android create avd -n <name> -t <target>
    

Cons

All of these methods have downsides though.

  1. Requires to pass the -noaudio flag each time. This means it can't be run from AVD manager.
  2. config.ini is reset each time an edit is made using AVD manager.
  3. Requires to explicitly set every property of the device instead of just being able to use a preset configuration.

Attempted (failed) solution

I decided it might help to just clone an existing device and disable the audio there.

However¸ this just created ~/.android/devices.xml and I couldn't fine any reference how to disable audio by default nor any ini files containing hardware definitions.

Question

Is it possible to create a predefined hardware configuration that has sound disabled by default? If so, how?

Community
  • 1
  • 1
Remco Haszing
  • 7,178
  • 4
  • 40
  • 83
  • "this just created ~/.android/avd/devices.xml" -- I don't have that file, but I do have `~/.android/devices.xml`. "I couldn't fine any reference how to disable audio by default" -- well, none of this is documented much, if at all. That being said, in `devices.xml`, I see various devices that I cloned from existing devices, and I see a `true` element that could be flipped to `false`. I do not see any elements related to audio output, though. I also have not tried changing `` to see what effects it may have. – CommonsWare Aug 08 '15 at 13:34
  • My mistake, it is in `~/.android/devices.xml` indeed. I believe disabling the audio output is even more important than the input. – Remco Haszing Aug 08 '15 at 13:37
  • If you're using Android Studio, this is a good solution: https://stackoverflow.com/a/64696876/1942551 – karlingen Dec 23 '21 at 09:04

0 Answers0