Recently, I faced an issue where I was depending on some Android APIs which were added only in API level 16 (Jelly Bean). I had my tests running on API level 21 and everything seemed OK. But then I realized that the code I was testing was run on API 21 every time but the
minSdkVersion of the project was
11. So I had to test my project on earlier versions of Android. And here I faced an issue where I needed my tests to be run on two emulators: one would be API level < 16 and the other would be API level >= 16.
As I was using Travis, I already had an emulator working for me but I haven’t found any documentation on how to run multiple emulators on Travis. So here are a few steps on how to get your multiple emulators working:
Include this in your
.travis.yml file in order to get more RAM. If you don’t, you’ll get container-based infrastructure which has only 4 GB. This can be somewhat risky because there should be enough space for your gradle build and two emulators.
|Memory||7.5 GB||4 GB max|
Information is taken from Travis CI official website.
Configure the Travis for it to download and update system images of
android-21. BTW, if you want to use
android-24 as the target SDK, be aware of this issue.
scripts/wait-for-first-emulator.sh is below (all credits to the script go here):
The only difference between
scripts/script.sh is also simple:
In this way you can launch two emulators and execute your test suite on two devices simultaneously.
Thanks for reading! The sample repo is here.comments powered by Disqus