This Docker image is designed to provide an environment with the Android SDK and necessary tools for Android development. It is based on Debian 12.5 and includes OpenJDK 17, Android SDK tools, and the required platforms for building Android applications.
- Base Image: Debian 12.5
- OpenJDK 17: Installed for Java-based Android development
- Android SDK: Includes Android SDK command-line tools and necessary platforms for Android development
- Locale Setup: Configured for both English and French locales
- Non-interactive Setup: Ensures that all installation steps are automated
- Docker installed on your machine.
-
Clone this repository or download the Dockerfile.
-
Build the Docker image by running the following command:
docker build -t gitlab-ci-android .
To build and push the Docker image to Docker Hub, follow these steps:
-
Build the image for a specific platform (e.g.,
linux/amd64
):docker buildx build --platform linux/amd64 -t sbellanger/gitlab-ci-android .
-
Tag the image for versioning:
docker tag sbellanger/gitlab-ci-android\:latest sbellanger/gitlab-ci-android:[TAG]
-
Push the image to Docker Hub:
docker push sbellanger/gitlab-ci-android:[TAG]
Before pushing the image to Docker Hub, you need to log in. Run the following command to authenticate:
docker login
You will be prompted to enter your Docker Hub username and password.
The image installs the Android SDK command-line tools and necessary platforms. The version of Android SDK tools is defined as 6858069. It automatically accepts Android SDK licenses.
- OpenJDK 17: Java Development Kit required for building Android applications.
- Curl: Used for downloading SDK tools.
- Git: For version control.
- Unzip: To unzip the Android SDK tools.
- Fontconfig and Locales: For proper rendering and localization.
The Docker image is configured with en_US.UTF-8 and fr_FR.UTF-8 locales for compatibility with Android development tools and scripts.
The following components are installed:
- Command-line tools: The latest Android SDK tools.
- Platform tools: For managing Android devices.
- Build tools: For building APKs (version 34.0.0).
- Android Platform: Targeting Android API level 34.
To start a container with the Android SDK, use the following command:
docker run -it gitlab-ci-android
This will open a shell inside the container with the Android SDK tools available.
You can integrate this Docker image into your GitLab CI pipeline for building Android projects. Below is an example .gitlab-ci.yml file:
stages:
- build
variables:
ANDROID_HOME: "/sdk"
ANDROID_SDK_ROOT: "/sdk"
GRADLE_USER_HOME: "/gradle"
before_script:
- export PATH="\$ANDROID_HOME/cmdline-tools/latest/bin:\$ANDROID_HOME/platform-tools:\$PATH"
- yes | sdkmanager --licenses
build_android:
stage: build
image: sbellanger/gitlab-ci-android\:latest
script:
- echo "Starting build process"
- sdkmanager "platforms;android-34" "build-tools;34.0.0"
- ./gradlew assembleRelease
only:
- master
If you'd like to contribute to this Docker image, feel free to open an issue or submit a pull request with improvements.