Running Android emulators in GitLab CI is very handy for running test suites on merge requests. Also, it lets you test on old Android versions even if you have no device with that Android version. This was announced as a release in a blog post
We use our own Docker images to support this:
Unfortunately, the quality control on the system-image
packages is spotty, so a number of them are not really usable. It is important to use the default
rather than google_apis
system-images they do not contain the Google Play and apps binary blobs, and because the Google apps seem to slow down the boot process a lot. Also, it seems the android-22
through android-27
system images seem to require less resources than the newer ones, so much so that they are unlikely to work at all for some projects.
Here are some example runs to see what works:
- all available system-images without KVM ("no accel") in regular shared runners:
- all available system-images with KVM in fdroid runners:
Usage
The fdroiclient setup uses YAML templates to make it easy to choose specific emulator setups, specifically, the test-template
, the connected-template
, and the kvm-template
.
We use the default image in fdroidclient like this:
no-accel 22 default x86:
<<: *test-template
<<: *connected-template
kvm 29 default x86_64:
<<: *kvm-template
This script can help you generate multiple entries:
for system_image in `sdkmanager --list|awk '{print $1}'|sort|grep ';android-[23][02-9]'|grep -F ';x86'|grep -E ';(default|google|microg)'|sort -u`; do
echo kvm `echo $system_image | cut -d - -f 3 | sed 's,;, ,g'`:
printf ' <<: *kvm-template\n\n'
done
Test image based on Google's
Google has their own scripts for creating Docker images for the Android emulator. This is an experimental project to do something like fdroid/ci-images-client with their images as a base:
microg system-images
The microg system-image repository is also included in the F-Droid setup. There are currently two images:
system-images;android-29;microg;x86_64
-
system-images;android-23;microg;x86
- requires emulator v28 or older because it lacks a "ranchu" kernel.