Sign inSign up

matheussouza/docker-android-build-tools

By matheussouza

•Updated about 3 years ago

Image
0

375

matheussouza/docker-android-build-tools repository overview

⁠Docker Android Build Tools

build Docker Image CI Codacy Badge Docker Image Size

⁠Introduction

An optimized Docker image that includes the Android SDK.

⁠What Is Inside

It includes the following components:

  • Debian 11
  • Java (OpenJDK)
    • 11
  • Android SDKs for platforms:
    • 33
  • Android build tools:
    • 33.0.0
  • cmake
  • Python (2.7.18)
  • Ruby (2.7.4), RubyGems (3.2.5)
  • fastlane (2.211.0)
  • jenv

⁠Pull Docker Image

The docker image is a 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 matheussouza/docker-android-build-tools

Hint: You can use a tag to a specific stable version, rather than latest of docker image, to avoid breaking your build. e.g. matheussouza/docker-android-build-tools:v1.0.0. Take a look at the Releases⁠ section, to see all the available releases.

⁠Usage

⁠Use the image to build an Android project

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):/app matheussouza/docker-android-build-tools bash -c 'cd /app; ./gradlew build'

To build .aab bundle release, use ./gradlew bundleRelease:

cd <android project directory>  # change working directory to your project root directory.
docker run --rm -v $(pwd):/app matheussouza/docker-android-build-tools bash -c 'cd /app; ./gradlew bundleRelease'

Run docker image with interactive bash shell:

docker run -it -v $(pwd):/app matheussouza/docker-android-build-tools /bin/bash

Add the following arguments to the docker command to cache the home gradle folder:

-v "$HOME/.dockercache/gradle":"/root/.gradle"

e.g.

docker run --rm -v $(pwd):/app  -v "$HOME/.dockercache/gradle":"/root/.gradle" matheussouza/docker-android-build-tools bash -c 'cd /project; ./gradlew build'
⁠Build an Android project with Bitbucket Pipelines⁠

If you have an Android project in a Bitbucket repository and want to use the pipeline feature to build it, you can simply specify this docker image. Here is an example of bitbucket-pipelines.yml:

image: matheussouza/docker-android-build-tools:latest

pipelines:
  default:
    - step:
        caches:
          - gradle
          - gradle-wrapper
          - android-emulator
        script:
          - bash ./gradlew assemble
definitions:
  caches:
    gradle-wrapper: ~/.gradle/wrapper
    android-emulator: $ANDROID_HOME/system-images/android-21

The caches are used to store downloaded dependencies⁠ from previous builds, to speed up the next builds.

⁠Choose the Android Compile, Build Tools and SDK Tools version

Java 11 is installed.

docker-android-build-tools versionAndroid Compile SDKBuild Tools versionSDK Tools version
v1.0.03030.0.38092744
v1.2.03333.0.09123335

If versions other than those listed are needed, just change the respective ENVs in Docerfile and build the image⁠.

⁠Build the Docker Image

If you want to build the docker image by yourself, you can use following command. The image itself is around 1.3 GB, so check your free disk space before building it.

docker build -t docker-android-build-tools .

⁠Contribution

If you want to enhance this docker image or fix something, feel free to send pull request⁠.

⁠References

Tag summary

Content type

Image

Digest

sha256:5b34742b4…

Size

646.5 MB

Last updated

about 3 years ago

docker pull matheussouza/docker-android-build-tools