{"id":13831851,"url":"https://github.com/mingchen/docker-android-build-box","last_synced_at":"2026-02-21T19:46:44.026Z","repository":{"id":37663805,"uuid":"72052556","full_name":"mingchen/docker-android-build-box","owner":"mingchen","description":"An optimized docker image includes Android, Kotlin, Flutter sdk.","archived":false,"fork":false,"pushed_at":"2025-12-24T04:08:51.000Z","size":489,"stargazers_count":605,"open_issues_count":1,"forks_count":238,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-12-25T17:48:23.028Z","etag":null,"topics":["bitbucket","docker-android","docker-image","dockerfile","dockerize","fastlane","flutter","kotlin","pipeline"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/mingc/android-build-box/","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mingchen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-10-26T23:20:09.000Z","updated_at":"2025-12-24T04:08:54.000Z","dependencies_parsed_at":"2023-11-15T05:25:12.650Z","dependency_job_id":"803470af-6539-420d-bcd1-244148e94ef3","html_url":"https://github.com/mingchen/docker-android-build-box","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/mingchen/docker-android-build-box","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mingchen%2Fdocker-android-build-box","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mingchen%2Fdocker-android-build-box/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mingchen%2Fdocker-android-build-box/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mingchen%2Fdocker-android-build-box/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mingchen","download_url":"https://codeload.github.com/mingchen/docker-android-build-box/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mingchen%2Fdocker-android-build-box/sbom","scorecard":{"id":648012,"data":{"date":"2025-08-11","repo":{"name":"github.com/mingchen/docker-android-build-box","commit":"00adcefacbd3669602510eabaf9e523ac8b06c3f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.2,"checks":[{"name":"Maintained","score":8,"reason":"10 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 8","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":3,"reason":"Found 4/11 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/docker-image.yml:1","Warn: no topLevel permission defined: .github/workflows/stale-issues-and-prs.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: test_projects/SampleProject/gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/docker-image.yml:34"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 25 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":1,"reason":"dependency not pinned by hash detected -- score normalized to 1","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/stale-issues-and-prs.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/mingchen/docker-android-build-box/stale-issues-and-prs.yml/master?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:39","Warn: containerImage not pinned by hash: Dockerfile:80","Warn: containerImage not pinned by hash: Dockerfile:153","Warn: containerImage not pinned by hash: Dockerfile:156","Warn: containerImage not pinned by hash: Dockerfile:162","Warn: containerImage not pinned by hash: Dockerfile:170","Warn: containerImage not pinned by hash: Dockerfile:193","Warn: containerImage not pinned by hash: Dockerfile:197","Warn: containerImage not pinned by hash: Dockerfile:201","Warn: containerImage not pinned by hash: Dockerfile:205","Warn: containerImage not pinned by hash: Dockerfile:221","Warn: containerImage not pinned by hash: Dockerfile:231","Warn: containerImage not pinned by hash: Dockerfile:257","Warn: containerImage not pinned by hash: Dockerfile:261","Warn: containerImage not pinned by hash: Dockerfile:266","Warn: containerImage not pinned by hash: Dockerfile:270","Warn: containerImage not pinned by hash: Dockerfile:273","Warn: containerImage not pinned by hash: Dockerfile:292","Warn: containerImage not pinned by hash: Dockerfile:301","Warn: containerImage not pinned by hash: Dockerfile:305","Warn: containerImage not pinned by hash: Dockerfile:309","Warn: containerImage not pinned by hash: Dockerfile:315","Warn: containerImage not pinned by hash: Dockerfile:322","Warn: containerImage not pinned by hash: Dockerfile:326","Warn: containerImage not pinned by hash: Dockerfile:332","Warn: containerImage not pinned by hash: Dockerfile:340","Warn: containerImage not pinned by hash: Dockerfile:347","Warn: containerImage not pinned by hash: Dockerfile:349","Warn: containerImage not pinned by hash: Dockerfile:353","Warn: containerImage not pinned by hash: Dockerfile:357","Warn: containerImage not pinned by hash: Dockerfile:364","Warn: containerImage not pinned by hash: Dockerfile:386","Warn: containerImage not pinned by hash: Dockerfile:392","Warn: containerImage not pinned by hash: Dockerfile:395","Warn: containerImage not pinned by hash: Dockerfile:398","Warn: containerImage not pinned by hash: Dockerfile:442","Warn: containerImage not pinned by hash: Dockerfile:462","Warn: containerImage not pinned by hash: Dockerfile:493","Warn: downloadThenRun not pinned by hash: Dockerfile:393","Warn: downloadThenRun not pinned by hash: Dockerfile:396","Warn: npmCommand not pinned by hash: Dockerfile:399-430","Warn: npmCommand not pinned by hash: Dockerfile:399-430","Warn: downloadThenRun not pinned by hash: .github/workflows/docker-image.yml:165","Info:   1 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   9 out of   9 third-party GitHubAction dependencies pinned","Info:   0 out of   3 downloadThenRun dependencies pinned","Info:   0 out of   2 npmCommand dependencies pinned","Info:   0 out of  38 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}}]},"last_synced_at":"2025-08-21T12:40:56.166Z","repository_id":37663805,"created_at":"2025-08-21T12:40:56.166Z","updated_at":"2025-08-21T12:40:56.166Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29691077,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T18:18:25.093Z","status":"ssl_error","status_checked_at":"2026-02-21T18:18:22.435Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitbucket","docker-android","docker-image","dockerfile","dockerize","fastlane","flutter","kotlin","pipeline"],"created_at":"2024-08-04T10:01:42.517Z","updated_at":"2026-02-21T19:46:44.008Z","avatar_url":"https://github.com/mingchen.png","language":"Dockerfile","readme":"# Docker Android Build Box\n\n[![docker icon](https://dockeri.co/image/mingc/android-build-box)](https://hub.docker.com/r/mingc/android-build-box/)\n[![Docker Image CI](https://github.com/mingchen/docker-android-build-box/actions/workflows/docker-image.yml/badge.svg)](https://github.com/mingchen/docker-android-build-box/actions/workflows/docker-image.yml)\n\n## Introduction\n\nAn optimized **Docker** image that includes the **Android SDK** and **Flutter SDK**.\n\n## What Is Inside\n\nThe *latest* image will always have the latest software installed, including the last 8 Android SDKs for platforms and associated build tools.\nThe Dockerhub description, accessible by clicking the Docker badge above, has an always up-to-date listing of the software installed on the *latest* image.\nPlease also see the [matrixes](COMPATIBILITY.md) file for details on the various software installed on the tagged release and the *latest* image.\n\nThe last **tagged** release includes the following components:\n\n* Ubuntu 22.04\n* Java - OpenJDK\n  * 8 (1.8)\n  * 11\n  * 17\n  * 21\n* Android SDKs for platforms:\n  * 28\n  * 29\n  * 30\n  * 31\n  * 32\n  * 33\n  * 34\n  * 35\n* Android build tools:\n  * 28.0.1 28.0.2 28.0.3\n  * 29.0.2 29.0.3\n  * 30.0.0 30.0.2 30.0.3\n  * 31.0.0\n  * 32.0.0\n  * 33.0.0 33.0.1 33.0.2 33.0.3\n  * 34.0.0\n  * 35.0.0\n* Android NDK - r28b\n* [Android bundletool](https://github.com/google/bundletool)\n* Android Emulator\n* cmake\n* TestNG\n* Python 3.8.10\n* Node.js 22, npm, React Native\n* Ruby, RubyGems\n* fastlane\n* Flutter 3.32.4\n* [jEnv](https://www.jenv.be)\n\n\n## Pull Docker Image\n\nThe docker image is automatically built publicly on *Github Action* based on the `Dockerfile` in this repo, there is no hidden stuff in it.\n\nTo pull the latest docker image:\n\n```sh\ndocker pull mingc/android-build-box:latest\n```\n\n**Hint:** You can use a tag to a specific stable version,\nrather than `latest` of docker image, to avoid breaking your build.\ne.g. `mingc/android-build-box:1.25.0`.\n\nTake a look at the [**Tags List**](https://github.com/mingchen/docker-android-build-box/tags) to see all the available tags, the [Changelog](CHANGELOG.md) to see the changes between tags, and the [Compatibility Matrices](COMPATIBILITY.md) to see matrices of the various software available, that is tag `1.2.0` has SDKs x, y, and z... etc.\n\n## Usage\n\n### Use the image to build an Android project\n\nPlease see the [caches section](#caches) for how to use caching.\n\nYou can use this docker image to build your Android project with a single docker command:\n\n```sh\ncd \u003candroid project directory\u003e  # change working directory to your project root directory.\ndocker run --rm -v `pwd`:/project mingc/android-build-box bash -c 'cd /project; ./gradlew build'\n```\n\nTo build `.aab` bundle release, use `./gradlew bundleRelease`:\n\n```sh\ncd \u003candroid project directory\u003e  # change working directory to your project root directory.\ndocker run --rm -v `pwd`:/project mingc/android-build-box bash -c 'cd /project; ./gradlew bundleRelease'\n```\n\nRun docker image with interactive bash shell:\n\n```sh\ndocker run -v `pwd`:/project -it mingc/android-build-box bash -l\n```\n\n### Caches\n\nPlease be aware that caching will not reduce the total disk space needed, but will increase it. For example, with the [Android SDK](#android-sdk-cache) this will potentially double the amound of space. First there is the space needed for the image itself, and then the space needed for the cache. For example for `1.25.0`, the image needs 16.2GB of space and then if one where to cache the SDK, without any changes, then there would be an additional 6GB of space needed; 16.2GB (raw image) + SDK Cache (6GB by default).\n\n#### jEnv Cache\n\nTo allow for the global java setting via jEnv, the file `/root/.jenv/version`, to be cached the simplest way is to cache the complete jEnv folder, `/root/.jenv/`.\n\nFirst create the directory on the host where jEnv will be cached. For this example it will be in `~/.dockercache/jenv/`:\n```sh\n# mkdir ~/.dockercache/jenv\n```\n\nSecond create a *named volume*, named `jenv-cache`. A *named volume* is necessary to allow the container's contents of jEnv to remain. The simplest manner is as follows:\n```sh\n# docker volume create --driver local --opt type=none --opt device=~/.dockercache/jenv/ --opt o=bind jenv-cache\n```\n\nAnd finally when you create / run the container, be sure to include the *named volume* by adding the following to the command:\n```sh\n-v jenv-cache:\"/root/.jenv/\"\n```\ne.g.\n```sh\n# docker run --rm -v jenv-cache:\"/root/.jenv/\" mingc/android-build-box bash -l `echo \"Hello World\"`\n```\n\n#### Gradle Cache\n\nAdd the following arguments to the docker command to cache the home gradle folder:\n```sh\n-v \"$HOME/.dockercache/gradle\":\"/root/.gradle\"\n```\ne.g.\n```sh\ndocker run --rm -v `pwd`:/project  -v \"$HOME/.dockercache/gradle\":\"/root/.gradle\"   mingc/android-build-box bash -c 'cd /project; ./gradlew build'\n```\n\nThe final step is to turn caching on by adding:\n```sh\norg.gradle.caching=true\n```\nto your `gradle.properties`. Either the project's `gradle.properties` or the global `gradle.properties` in `$HOME/.dockercache/gradle/gradle.properties`.\n\n#### Android SDK Cache\n\nThe benefit of caching the SDK is it allows for SDK platforms / build-tools to be updated / removed in the image. For example, in `1.25.0` one could drop SDKs 27, 28, and 29; as well as adding build-tools 34. As of `1.25.0` `/opt/android-sdk/` will need about 6G of disk space.\n\nAs with the [jEnv cache](#jenv-cache) a named volume will be needed.\n\nFirst create the directory on the host where the SDKs will be cached. For this example it will be in `~/.dockercache/android-sdk/`:\n```sh\n# mkdir ~/.dockercache/android-sdk\n```\n\nSecond create a named volume, named `android-sdk-cache`. A *named volume* is necessary to allow the container's contents to remain. The simplest manner is as follows:\n```sh\n# docker volume create --driver local --opt type=none --opt device=~/.dockercache/android-sdk/ --opt o=bind android-sdk-cache\nandroid-sdk-cache\n```\n\nAnd finally when you create / run the container, be sure to include the *named volume* by adding the following to the command:\n```sh\n-v android-sdk-cache:\"/opt/android-sdk/\"\n```\ne.g.\n```sh\n# docker run --rm -v android-sdk-cache:\"/opt/android-sdk/\" mingc/android-build-box bash -l\n```\n\nNow within the container one may interact with the sdkmanager to install build tools, platforms, etc as needed. Some brief commands...\nto list what is installed:\n```sh\n# sdkmanager --list_installed\n```\nTo uninstall a platform:\n```sh\n# sdkmanager --uninstall 'platforms;android-26'\n```\nTo install a platform:\n```sh\n# sdkmanager --install 'platforms;android-26'\n```\nBoth the `--install` and `--uninstall` flags allow for a list to be passed, that is:\n```sh\n# sdkmanager --uninstall 'platforms;android-26' 'platforms;android-27'\n```\n\nFull documentation is available [here](https://developer.android.com/studio/command-line/sdkmanager).\n### Suggested gradle.properties\n\nSetting the following `jvmargs` for gradle are suggested:\n* `-Xmx8192m`\n  * Sets the max memory the JVM may use to 8192m, values of g, that is gb, are supported.\n* `-XX:MaxMetaspaceSize=1024m`\n  * Must set due to gradle bug gradle/gradle#19750, else is unbounded.\n* `-XX:+UseContainerSupport`\n  * Allow JVM to know it's in a container, optional as is default.\n* `-XX:MaxRAMPercentage=97.5`\n  * Allow JVM to use at most 97.5% of the RAM in container, can be set to 1.\n\nThe total memory available to the container should be greater than the Xmx value + the MaxMetaspaceSize. For example, if 10gb is allocated to the container, and using the already listed values, then we have 10gb = 8gb (Xmx) + 1gb (MaxMetaspaceSize) + 1gb (overhead / buffer / other). If the container has 4gb of memory available than the following would be reasonable settings: 4gb = 3072m (Xmx) + 756m (MaxMetaspaceSize) + 256mb (overhead / etc).\n\nIn total the `gradle.properties` would be:\n```sh\norg.gradle.jvmargs=-Xmx8192m -XX:MaxMetaspaceSize=1024m -XX:+UseContainerSupport -XX:MaxRAMPercentage=97.5\n```\nor\n```sh\norg.gradle.jvmargs=-Xmx3072m -XX:MaxMetaspaceSize=756m -XX:+UseContainerSupport -XX:MaxRAMPercentage=97.5\n```\n\n### Build an Android project with [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines)\n\nIf you have an Android project in a Bitbucket repository and want to use the pipeline feature to build it,\nyou can simply specify this docker image.\nHere is an example of `bitbucket-pipelines.yml`:\n\n```yml\nimage: mingc/android-build-box:latest\n\npipelines:\n  default:\n    - step:\n        caches:\n          - gradle\n          - gradle-wrapper\n          - android-emulator\n        script:\n          - . ~/.bash_profile\n          - jenv global 11  # switch java version\n          - bash ./gradlew assemble\ndefinitions:\n  caches:\n    gradle-wrapper: ~/.gradle/wrapper\n    android-emulator: $ANDROID_HOME/system-images/android-21\n```\n\nThe caches are used to [store downloaded dependencies](https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html) from previous builds, to speed up the next builds.\n\n### Build a Flutter project with [Github Actions](https://github.com/features/actions)\n\nHere is an example `.github/workflows/main.yml` to build a Flutter project with this docker image:\n\n```yml\nname: CI\n\non: [push]\n\njobs:\n  build:\n\n    runs-on: ubuntu-20.04\n    container: mingc/android-build-box:latest\n\n    steps:\n    - uses: actions/checkout@v3\n    - uses: actions/cache@v3\n      with:\n        path: /root/.gradle/caches\n        key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}\n        restore-keys: |\n          ${{ runner.os }}-gradle-\n    - name: Build\n      run: |\n        echo \"Work dir: $(pwd)\"\n        echo \"User: $(whoami)\"\n        flutter --version\n        flutter analyze\n        flutter build apk\n    - name: Archive apk\n      uses: actions/upload-artifact@v3\n      with:\n        name: apk\n        path: build/app/outputs/apk\n    - name: Test\n      run: flutter test\n    - name: Clean build to avoid action/cache error\n      run: rm -fr build\n```\n\nNote: For improved security reference the action directly by commit hash and not tag. Please see our own [action](.github/workflows/docker-image.yml) for an examples.\n\n### Run an Android emulator in the Docker build machine\n\nUsing guidelines from...\n\n* https://medium.com/@AndreSand/android-emulator-on-docker-container-f20c49b129ef\n* https://spin.atomicobject.com/2016/03/10/android-test-script/\n* https://paulemtz.blogspot.com/2013/05/android-testing-in-headless-emulator.html\n\n...You can write a script to create and launch an ARM emulator, which can be used for running integration tests or instrumentation tests or unit tests:\n\n```sh\n#!/bin/bash\n\n# Arm emulators can be quite slow. For this reason it is convenient\n# to increase the adb timeout to avoid errors.\nexport ADB_INSTALL_TIMEOUT=30\n\n# Download an ARM system image to create an ARM emulator.\nsdkmanager \"system-images;android-22;default;armeabi-v7a\"\n\n# Create an ARM AVD emulator, with a 100 MB SD card storage space. Echo \"no\"\n# because it will ask if you want to use a custom hardware profile, and you don't.\n# https://medium.com/@AndreSand/android-emulator-on-docker-container-f20c49b129ef\necho \"no\" | avdmanager create avd \\\n    -n Android_5.1_API_22 \\\n    -k \"system-images;android-22;default;armeabi-v7a\" \\\n    -c 100M \\\n    --force\n\n# Launch the emulator in the background\n$ANDROID_HOME/emulator/emulator -avd Android_5.1_API_22 -no-skin -no-audio -no-window -no-boot-anim -gpu off \u0026\n\n# Note: You will have to add a suitable time delay, to wait for the emulator to launch.\n```\n\nNote that x86_64 emulators are not currently supported. See [Issue #18](https://github.com/mingchen/docker-android-build-box/issues/18) for details.\n\n### Choose the system Java version\n\nAs of `1.23.0`, `jenv` is used to switch `java` versions. Versions prior to `1.23.0` used `update-alternatives`; brief documentation is available [here](https://github.com/mingchen/docker-android-build-box/tree/95fde4a765cecf6d43b084190394fd43bef5bfd1#choose-the-system-java-version).\n\nPlease also see the [installed java versions matrix](COMPATIBILITY.md#Installed-Java-Versions-Matrix) for the installed java versions and [jEnv Cache](#jenv-cache) on how to cache the *global* java version.\n\nTo allow `jenv` work properly, please run following command before any `jenv` command:\n\n```sh\n. ~/.bash_profile\n```\n\nThe following documentation is for `jenv`. Please note that if the container is removed, that is run with the `--rm` flag, *global* changes will not persist unless jEnv is cached.\n\nList all the available `java` versions:\n\n```sh\n# jenv versions\n  system\n  11\n  11.0\n  11.0.17\n  17\n* 17.0 (set by /root/.jenv/version)\n  17.0.5\n  1.8\n  1.8.0.352\n  openjdk64-11.0.17\n  openjdk64-17.0.5\n  openjdk64-1.8.0.352\n```\n\nSwitch *global* `java` version to **Java 8**:\n\n```sh\nroot@f7e7773edb7f:/project# jenv global 1.8\nroot@f7e7773edb7f:/project# java -version\nopenjdk version \"1.8.0_352\"\nOpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~20.04-b08)\nOpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)\n```\n\nSwitch *global* `java` version to **Java 11**:\n\n```sh\nroot@f7e7773edb7f:/project# jenv global 11\nroot@f7e7773edb7f:/project# java -version\nopenjdk version \"11.0.17\" 2022-10-18\nOpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu220.04)\nOpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu220.04, mixed mode, sharing)\n```\n\nSwitch local, that is current folder, `java` version to **Java 1.8**:\n\n```sh\nroot@f7e7773edb7f:/project# jenv local 1.8\nroot@f7e7773edb7f:/project# java -version\nopenjdk version \"1.8.0_352\"\nOpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~20.04-b08)\nOpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)\nroot@f7e7773edb7f:/project# cd ..\nroot@f7e7773edb7f:/# java -version\nopenjdk version \"17.0.5\" 2022-10-18\nOpenJDK Runtime Environment (build 17.0.5+8-Ubuntu-2ubuntu120.04)\nOpenJDK 64-Bit Server VM (build 17.0.5+8-Ubuntu-2ubuntu120.04, mixed mode, sharing)\n```\n\nThis can also be done by creating a `.java-version` file in the directory. See the SampleProject file [here](test_projects/SampleProject/.java-version) for an example.\n\n## Build the Docker Image\n\nCheck your free disk space before building it as the image can be anywhere from ~10GB - ~16GB in size.\n\nDocker buildx is used so at a minimum Docker Engine version 19.03 or later is required.\n\nIf you want to build the docker image by yourself, you can use following command.\n\n```sh\ndocker buildx build -t android-build-box .\n```\n\nThere are three build targets. The default is `complete-flutter`. The other two targets available are `minimal` and `complete`.\n\n| Build Target | SDK CLI Tools | jEnv | platform-tools; | platforms / build-tools | bundletool | NDK | Fastlane / Rake  | Node, etc | Flutter |\n|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|\n| minimal | ✅\u003c!--SDK CLI Tools--\u003e  | ✅\u003c!--jEnv--\u003e | ✅\u003c!--platform-tools;--\u003e | ❌\u003c!--platforms/build-tools--\u003e | ❌\u003c!--bundletool--\u003e |❌\u003c!--NDK--\u003e | ❌\u003c!--Fastlane/Rake--\u003e | ❌\u003c!--Node--\u003e | ❌\u003c!--Flutter--\u003e |\n| complete | ✅\u003c!--SDK CLI Tools--\u003e  | ✅\u003c!--jEnv--\u003e | ✅\u003c!--platform-tools;--\u003e | ✅\u003c!--platforms/build-tools--\u003e | ✅\u003c!--bundletool--\u003e | ✅\u003c!--NDK--\u003e | ✅\u003c!--Fastlane/Rake--\u003e | ✅\u003c!--Node--\u003e | ❌\u003c!--Flutter--\u003e |\n| complete-flutter | ✅\u003c!--SDK CLI Tools--\u003e  | ✅\u003c!--jEnv--\u003e | ✅\u003c!--platform-tools;--\u003e | ✅\u003c!--platforms/build-tools--\u003e | ✅\u003c!--bundletool--\u003e | ✅\u003c!--NDK--\u003e | ✅\u003c!--Fastlane/Rake--\u003e | ✅\u003c!--Node--\u003e | ✅\u003c!--Flutter--\u003e |\n\nNo matter the build target chosen, the default will be to grab the latest software. This means the latest SDK CLI tools, jEnv, etc. With regards to the platforms; / build-tools the last 8 platforms are used as well as all associated build tools and any extensions.\n\nIf you wish to use the version of software specified in the file in the `_TAGGED` build argument must be set to `tagged`. If you wish to specifiy the software version to be installed, then the `_TAGGED` argument must be set as mentioned, and the `_VERSION` build argument must be set to the desired version.\n\nFor example, build target of `minimal` with SDK CLI tool `4333796` and jEnv `0.5.6`:\n```sh\ndocker buildx build --target minimal --build-arg ANDROID_SDK_TOOLS_TAGGED=\"tagged\" --build-arg ANDROID_SDK_TOOLS_VERSION=\"4333796\" --build-arg JENV_TAGGED=\"tagged\" --build-arg JENV_RELEASE=\"0.5.6\"\n```\n\nPlease see the [Dockerfile](Dockerfile) for all the variable names. Also note, that jEnv is special so the version is specified by the argument `JENV_RELEASE`.\n\n## Changelog\n\nPlease see the dedicated changelog [here](CHANGELOG.md).\n\n## Compatibility\n\nPlease see the compatibility matrices [here](COMPATIBILITY.md).\n\n## Contribution\n\nIf you want to enhance this docker image or fix something,\nfeel free to send a [pull request](https://github.com/mingchen/docker-android-build-box/pull/new/master).\n\nPlease also preface commits with `DOCS:` when editing any documentation and `CI:` when editing `.github/workflows/`.\n\nAlso note that building / testing can use up a lot of space. After developing a feature and prune-ing, routinely 100GB of space is freed.\n\n## References\n\n* [Dockerfile reference](https://docs.docker.com/engine/reference/builder/)\n* [Best practices for writing Dockerfiles](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/)\n* [Build your own image](https://docs.docker.com/engine/getstarted/step_four/)\n* [uber android build environment](https://hub.docker.com/r/uber/android-build-environment/)\n* [Refactoring a Dockerfile for image size](https://blog.replicated.com/refactoring-a-dockerfile-for-image-size/)\n* [Label Schema](http://label-schema.org/)\n","funding_links":[],"categories":["Dockerfile"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmingchen%2Fdocker-android-build-box","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmingchen%2Fdocker-android-build-box","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmingchen%2Fdocker-android-build-box/lists"}