Linux Emulator Woe? Try No Audio!

In recent months, the Android SDK emulator had been consuming a lot of CPU cycles on my Ubuntu development machine, usually taking over all of one of my CPU cores. Not only does it affect the speed of whatever else I am doing, but it caused the CPU fan to run nearly continously. However, I am old and jaded, and so for a while I just chalked this up to being “another one of those things” that comes with developing for Android.

Then, I ran across this Stack Overflow question, which cited a much older Stack Overflow answer with a recipe for cutting CPU consumption: getting rid of the audio.

I tried it, and my emulator is much happier now. Admittedly, I cannot test audio work with it, but I tend to use hardware for that anyway.

To affect this change, stop the emulator and edit ~/.android/.../config.ini in your favorite text editor, where ... will be based on the name of one of your AVDs. In there, find the hw.audioInput=yes line, and replace it with:

hw.audioInput=no
hw.audioOutput=no

Save the file, start your emulator, and, if you’re like me, you will see results. Another approach, if you run your emulator from the command line, is to just tuck the -noaudio switch in the command.

Now, the Stack Overflow question that I mentioned is trying to fix one of the lingering issues with this approach: if you edit this AVD in the AVD Manager, your audio settings will be flipped back to their original values, requiring you to edit the config.ini file again. If anyone has any advice on how to create a hardware profile that keeps the audio settings off, post an answer on that question!

For what it’s worth, this outstanding issue seems to be related, though I have not tried collecting emulator logs.