A docker image build with Android build environment.
It includes the following components:
The docker image is publicly automated build on Docker Hub based on the Dockerfile in this repo, so there is no hidden stuff in it. To pull the latest docker image:
docker pull mingc/android-build-box:latest
Hint: Use tag to sepecific a stable version rather than latest of docker image to avoid break your buid. e.g. mingc/android-build-box:1.8.0. Checkout Tags (bottom of this page) to see all the available tags.
You can use this docker image to build your Android project with a single docker command:
cd <android project directory> # change working directory to your project root directory.
docker run --rm -v `pwd`:/project mingc/android-build-box bash -c 'cd /project; ./gradlew build'
Run docker image with interactive bash shell:
docker run -v `pwd`:/project -it mingc/android-build-box bash
If you have an Android project in a Bitbucket repository and want to use its pipeline to build it, you can simply specify this docker image.
Here is an example of bitbucket-pipelines.yml
image: mingc/android-build-box:latest
pipelines:
default:
- step:
caches:
- gradle
- gradlewrapper
- androidavd
script:
- bash ./gradlew assemble
definitions:
caches:
gradlewrapper: ~/.gradle/wrapper
androidavd: $ANDROID_HOME/.android/avd
The caches are used to store downloaded dependencies from previous builds, to speed up the next builds.
Using guidelines from https://medium.com/@AndreSand/android-emulator-on-docker-container-f20c49b129ef and https://spin.atomicobject.com/2016/03/10/android-test-script/ and https://paulemtz.blogspot.com/2013/05/android-testing-in-headless-emulator.html , you can use a script to create and launch an ARM emulator, which can be used for running integration tests or instrumentation tests or unit tests:
#!/bin/bash
# Download an ARM system image to create an ARM emulator.
sdkmanager "system-images;android-16;default;armeabi-v7a"
# Create an ARM AVD emulator, with a 100 MB SD card storage space. Echo "no"
# because it will ask if you want to use a custom hardware profile, and you don't.
# https://medium.com/@AndreSand/android-emulator-on-docker-container-f20c49b129ef
echo "no" | avdmanager create avd \
-n Android_4.1_API_16 \
-k "system-images;android-16;default;armeabi-v7a" \
-c 100M \
--force
# Launch the emulator in the background
$ANDROID_HOME/emulator/emulator -avd Android_4.1_API_16 -no-skin -no-audio -no-window -no-boot-anim -gpu off &
Note that x86_64 emulators are not currently supported. See Issue #18 for details.
If you want to build the docker image by yourself, you can use following command. The image itself is more than 5 GB, check your free disk space before building it.
docker build -t android-build-box .
Use tag to sepecific a stable version rather than latest of docker image to avoid break your buid. e.g. mingc/android-build-box:1.8.0
If you want to enhance this docker image or fix something, feel free to send pull request.
Content type
Image
Digest
Size
4.7 GB
Last updated
over 7 years ago
docker pull senorsen/android-build-box