Android Testing in Headless Emulator

When testing Android applications you have to rely on running the tests in the emulator or a device attached to your computer. However, if you want to follow a continuous integration workflow for Android development, you might need a headless emulator that runs in a non-graphical environment. For instance, I have been using Travis CI and Gradle for automating Android builds.

To completely avoid showing the emulator interface (headless emulator) you need to start the emulator with some options in your terminal.

First, you can create an specific Android AVD as follows:

android create avd --force -n test -t android-17 --abi armeabi-v7a

Then, to run the headless emulator:

emulator -avd test -no-skin -no-audio -no-window

The '-no-skin' option removes the emulator buttons such as the home and other hardware keyboard buttons.

The '-no-audio' option disables the audio support.

Finally, the '-no-window' option disables the emulator's graphical window display.

Now yo can use this emulator to run your tests.

Popular posts from this blog

Automating Android builds with Gradle