Docker image to build an Android app *.apk.
The image contains the latest Android SDK tools, Gradle 8.3 and the Android SDK platform packages from packages.txt.
This repository is configured with GitHub Actions to automatically build and push Docker images when tags are pushed:
git tag v1.0.0 && git push origin v1.0.0)your-dockerhub-username/android-sdk:latestyour-dockerhub-username/android-sdk:v1.0.0Before using, set these secrets in your GitHub repository settings:
DOCKER_HUB_USERNAME: Your Docker Hub usernameDOCKER_HUB_TOKEN: Your Docker Hub access tokenNote: Replace
your-dockerhub-usernamein the workflow file with your actual Docker Hub username.
The releases tags are oriented on the base of the Build Tools version from packages.txt.
The image can be used on different cloud build services or own hosted pipeline solutions like Travis CI, CircleCI or GitLab CI/CD.
CircleCI supports the direct specification of a Docker image and checks out the source code in it: https://circleci.com/docs/2.0/circleci-images/
Therefore you execute your CI script directly in the container.
Example:
# .circleci/config.yml version: 2.1 jobs: build: docker: - image: mobiledevops/android-sdk-image:34.0.0 steps: - checkout - run: name: Android Build command: ./gradlew clean assembleRelease
Example Project: https://github.com/mobiledevops/android-ci-demo
To use a Docker container on Travis CI, you have to pull, run and execute it manually because Travis CI has no Docker executor: https://docs.travis-ci.com/user/docker/
And to prevent to do a new checkout of the source code in the Docker image, you can copy the code into the container via tar (see https://docs.docker.com/engine/reference/commandline/cp/).
To execute your CI script, use docker exec with the container name.
Example:
# .travis.yml dist: bionic services: - docker env: - DOCKER_IMAGE=mobiledevops/android-sdk-image:34.0.0 before_install: - docker pull $DOCKER_IMAGE - docker run --name android_ci -t -d $DOCKER_IMAGE /bin/sh - tar Ccf . - . | docker exec -i android_ci tar Cxf /home/mobiledevops/app - script: - docker exec android_ci ./gradlew clean assembleRelease
Example Project: https://github.com/mobiledevops/android-ci-demo
GitLab CI/CD supports to run jobs on provided Docker images: https://docs.gitlab.com/runner/executors/docker.html
Therefore you execute your CI script directly in the container.
Example:
# .gitlab-ci.yml image: mobiledevops/android-sdk-image:34.0.0 stages: - build release_build: stage: build tags: - shared script: - ./gradlew clean assembleRelease
Example Project: https://gitlab.com/mobiledevops/android-ci-demo