How to test and build your Android applications using Gitlab CI
Could be a guest post of the people involved with the Unofficial GitLab client for Android,
https://gitlab.com/u/Michi302 seems to contribute to CE also.
# Notes
- https://gitlab.com/asura/android
- http://stackoverflow.com/questions/24942751/generating-android-build-with-gitlab-ci
- Make use of artifacts to upload nightly builds of apks
- Dockerfile for Android CI https://gist.github.com/eluleci/f9904382c1496fb81079
- Android development environment for ubuntu precise (12.04 LTS) https://github.com/ahazem/android-dockerfile
- Android apps that could use GitLab CI:
- https://github.com/syncthing/syncthing-android
Objective
Most people understand the benefits of continuous integration, but setting it up for Android can be a hassle. This article will outline setting up and running tests on an Android Studio project with Gradle on Gitlab's CI
- Learn how to setup an Android build on Gitlab's CI
- Learn how to run UI (Expresso) tests on an emulator
Outline
Setting up the Android Project for testing
- We'll install all of the Android dependancies using this gradle plugin.
- We'll start with this sample project from my repo
Setting up the CI environment.
- Using an Ubuntu runner, similar to the iOS post
- Setup any Android specific stuff.
Get the project to build
- How to save the APK as an artifact (This should probably be after the tests pass right?)
Get the JUnit tests to run
- Pretty straight forward, just a gradle invocation.
(Expresso) tests to run.
Get the UI- This is the tricky part! Getting an emulator running in a CI environment is non-trivial.
- We'll then setup this travis script to start an emulator.
Next Steps (Covered in another post)
- Speed up builds using a precompiled docker image with the build environment
- Publish to Google Play using this gradle plugin