docker-android provides general purpose docker images to run CI steps of Android project. Docker allows you to provide a replicable environment, which does not change with the host machine or the CI service. It should work out of the box on any CI/CD service providing docker support. The image is providing standard tools to build and test Android application:
- Android SDK (optionally Android NDK)
- Fastlane first class support
- Java JDK
- Google Cloud CLI, to support Firebase Test Lab
CI/CD service | Tested |
---|---|
GitHub Actions | ✅ |
GitLab CI | ✅ |
Circle CI | 🚧 |
Travis CI | 🚧 |
Images are built to have first class support for Fastlane.
Ruby versions in normal maintenance
mode are installed using rbenv.
If you are using a Fastlane plugin which requires a native library:
- Install it using
apt-get update && apt-get -y install <lib>
in your CI workflow. - Comment faberNovel#78 so that we can keep track of missing native libraries and add them to the next image version.
Images support multiple JDK, using Jenv.
The default JDK is JDK 11, but JDK 8 is also supported for Android API 30 or lower (use jenv global 1.8
).
To choose a JDK, make sure the script executes on a bash shell, then use Jenv to set the desired version:
jobs:
my_android_job:
defaults:
run:
shell: bash
steps:
- name: Jenv
run: |
eval "$(jenv init -)"
jenv global {VERSION}
Github workflows can run inside Docker images using container
attribute after runs-on
:
name: GitHub Action sample
on:
push:
branches:
- develop
jobs:
my_android_job:
runs-on: ubuntu-22.04 # Works also with self hosted runner supporting docker
container:
image: docker://fabernovel/android:api-29-v1.1.0
steps:
- name: Checkout
uses: actions/checkout@v2.1.0
- name: Ruby Setup
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
env:
ImageOS: ubuntu20
- name: Gradle cache
uses: actions/cache@v3
with:
path: |
/root/.gradle/caches
/root/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Fastlane
run: bundle exec fastlane my_lane
You can also use the provided Github Action.
However, caching won't work and you can expect longer build times.
docker-android-tag
should be one of the tags found in Fabernovel Hub Registry Tags:
name: GitHub Action sample
on:
push:
branches:
- develop
jobs:
my_android_job:
runs-on: ubuntu-22.04 # Works also with self hosted runner supporting docker
steps:
- name: Checkout
uses: actions/checkout@v2.1.0
- name: Exec fastlane
uses: fabernovel/docker-android
with:
docker-android-tag: api-29-ndk-v1.1.0
exec: |
bundle install;
bundle exec fastlane my_lane
docker-android images are hosted on DockerHub.
We provide stable and snapshot variants for latest Android API levels, including or not native SDK.
We use the following tagging policy:
API-NDK-GCLOUD-VERSION
API
the Android API to use, likeapi-28
,api-29
NDK
is the presence or not of the Android NDK in the imageGCLOUD
is the presence or not of the Google Cloud SDK in the image. (the gcloud sdk is needed for Firebase Test Lab for example).VERSION
is the image version. Check Versions
snapshot
versions are build on each push ondevelop
branch- Release versions
v*
on each GitHub Release
Image description (software and their versions) is provided as md files.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
You can change image settings via its Dockerfile. You can build, test, and deploy image using ci_cd.sh script. You need to install docker first. All scripts must be POSIX compliants.
usage: ./ci_cd.sh [--android-api 29] [--build-tools "29.0.3"] [--build] [--test]
--android-api <androidVersion> Use specific Android version from `sdkmanager --list`
--build-tools <version> Use specific build tools version
--android-ndk Install Android NDK
--gcloud Install Google Cloud SDK
--ndk-version <version> Install a specific Android NDK version from `sdkmanager --list`
--build Build image
--test Test image
--large-test Run large tests on the image (Firebase Test Lab for example)
--deploy Deploy image
--desc Generate a .md file in /desc/ouput folder describing the builded image, on host machine