在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):mingchen/docker-android-build-box开源软件地址(OpenSource Url):https://github.com/mingchen/docker-android-build-box开源编程语言(OpenSource Language):Dockerfile 70.2%开源软件介绍(OpenSource Introduction):Docker Android Build BoxIntroductionAn optimized Docker image that includes the Android SDK and Flutter SDK. What Is InsideIt includes the following components:
Pull Docker ImageThe docker image is a publicly automated build on Docker Hub
based on the docker pull mingc/android-build-box:latest Hint: You can use a tag to a specific stable version,
rather than UsageUse the image to build an Android projectYou 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' To build 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 bundleRelease' Run docker image with interactive bash shell: docker run -v `pwd`:/project -it mingc/android-build-box 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`:/project -v "$HOME/.dockercache/gradle":"/root/.gradle" mingc/android-build-box bash -c 'cd /project; ./gradlew build' Bitbucket PipelinesBuild an Android project withIf 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 image: mingc/android-build-box: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. Github ActionsBuild a Flutter project withHere is an example name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-18.04
container: mingc/android-build-box:latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: /root/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build
run: |
echo "Work dir: $(pwd)"
echo "User: $(whoami)"
flutter --version
flutter analyze
flutter build apk
- name: Archive apk
uses: actions/upload-artifact@v1
with:
name: apk
path: build/app/outputs/apk
- name: Test
run: flutter test
- name: Clean build to avoid action/cache error
run: rm -fr build Run an Android emulator in the Docker build machineUsing guidelines from...
...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: #!/bin/bash
# Arm emulators can be quite slow. For this reason it is convenient
# to increase the adb timeout to avoid errors.
export ADB_INSTALL_TIMEOUT=30
# Download an ARM system image to create an ARM emulator.
sdkmanager "system-images;android-22;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_5.1_API_22 \
-k "system-images;android-22;default;armeabi-v7a" \
-c 100M \
--force
# Launch the emulator in the background
$ANDROID_HOME/emulator/emulator -avd Android_5.1_API_22 -no-skin -no-audio -no-window -no-boot-anim -gpu off &
# Note: You will have to add a suitable time delay, to wait for the emulator to launch. Note that x86_64 emulators are not currently supported. See Issue #18 for details. Choose the system Java versionBoth Java 1.8 and Java 11 are installed.
Use List all the available # update-alternatives --list java
/usr/lib/jvm/java-11-openjdk-arm64/bin/java
/usr/lib/jvm/java-8-openjdk-arm64/jre/bin/java Switch current # update-alternatives --set java /usr/lib/jvm/java-8-openjdk-arm64/jre/bin/java
update-alternatives: using /usr/lib/jvm/java-8-openjdk-arm64/jre/bin/java to provide /usr/bin/java (java) in manual mode
root@9b816ba2e3cb:/project# java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode) Switch current # update-alternatives --set java /usr/lib/jvm/java-11-openjdk-arm64/bin/java
update-alternatives: using /usr/lib/jvm/java-11-openjdk-arm64/bin/java to provide /usr/bin/java (java) in manual mode
root@9b816ba2e3cb:/project# java -version
openjdk version "11.0.14" 2022-01-18
OpenJDK Runtime Environment (build 11.0.14+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.14+9-Ubuntu-0ubuntu2.20.04, mixed mode) Build the Docker ImageIf you want to build the docker image by yourself, you can use following command. The image itself is around 5 GB, so check your free disk space before building it. docker build -t android-build-box . TagsYou can use a tag to a specific stable version, rather than Note: versions 1.24.0
1.23.1
1.23.0NOTE: missed this tag in DockerHub due to a github action error, should use
1.22.0
1.21.1
1.21.0
1.20.0
1.19.0
1.18.0
1.17.0
1.16.0
1.15.0
1.14.0
1.13.0
1.12.0
1.11.2
1.11.1
1.11.0
1.10.0
1.9.0
1.8.0
1.7.0
1.6.0
1.5.1
1.5.0
1.4.0
1.3.0
1.2.0
1.1.2
1.1.1
1.1.0
1.0.0
ContributionIf you want to enhance this docker image or fix something, feel free to send pull request. References
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论