Android Emulators on Travis-CI

Maurice McCabe
3 min readOct 11, 2018

--

As most android developers probably already know, it is not possible to run the x86 android emulators on most cloud CI platforms. This is because the hypervisors that many cloud vendors use are configured NOT to support nested VMs. So companies like Travis-CI and Cirrus-CI do not offer support for nested VMs. This limits integration testing to servers and/or hypervisors that have hardware acceleration enabled. Which often means having to support that capability in-house. This is a considerable expense and resource sink. So what is an android developer to do?

First a little backdrop: in the good old days Google shipped an arm-based emulator that ran without requiring hardware acceleration and could run in the cloud. Then Google released an x86-based emulator that runs faster (requires hardware acceleration) but that does not run in the could. Then it stopped releasing support for arm-based emulators… for some reason.

Nowadays, if an android developer wants to run an emulator in the cloud all is not lost. If the app does not require features in more recent emulators, in particular post android-25 (which there should be many), then it is possible to fire-up one of the arm-based emulators in the cloud. You may be surprised to see that your integration tests will pass, albeit, slower than you may be used to.

Now, the problem is that many CI vendors, including Travis-CI, do not offer support for running any android emulators (after all the latest ones don’t run on the cloud). So if you want to run an arm-based emulator on the cloud you have to figure it out yourself. Not always an easy task. Luckily support is available online if you can piece it together.

I went thru this process and was able to fire-up an emulator on Travis-CI and run integration tests, on both linux and mac. It should work on other CI vendors too and can even be bundled into a Docker image for local fast iteration testing.

In fact, I created a test bench on Travis-CI that attempts to start-up a bunch of arm-based emulators and was able to get most running with the latest android-28 tools. (Android Tools does not care what emulator it runs. It’s up to the developer to set-up the emulator they want.)

Here is a partial screen shot of the emulators running on Travis-CI with their startup times:

This is the .travis.yml file I use to fire-up the emulators.

Here is the build of this project:

The one I currently use for testing is the ‘android-22’ image with the ‘default;armeabi-v7a’ and it works fine with the ‘android-28’ tools. Though I could probably switch to the last supported arm-based emulator ‘android-25’ with ‘google_apis;arm64-v8a’. Just have no reason to so far.

Here is an example of a build that uses an android emulator in the cloud to run integration tests. It is using flutter which runs on both android and ios. The flutter integration tests also run on both android and ios.

You can find the complete source code at:

Let me know if you get another arm-based emulator running on the cloud. Maybe one day, either cloud vendors will support embedded VM’s or Google will decide to resume release of Arm emulators.

Apple does not have this problem, the xCode simulator works on the cloud without a problem and supports their latest iPhone hardware.

In a follow-up article I will show how to run Flutter unit, widget and integration tests on Travis with code coverage running on the iPhone simulator and the Android emulator.

Let me know if you have any questions about running arm-based emulators, either here or on GitHub and like, subscribe and share for more mobile developer articles. I’ll be happy to respond 🤓👍.

--

--