This is the image for building and testing Android applications. It contains Android SDK.
How to update android-builder image#
- Build the image to test your changes
Run Build android-builder (internal) teamcity configuration.
You will see the tag in stdout:
Published the image <docker registry>/android/builder:<tag>
If you need to test locally before publishing:
# Docker registry to further publishing
export DOCKER_REGISTRY=...
# DockerHub credentials (optional)
export DOCKER_HUB_USERNAME=...
export DOCKER_HUB_PASSWORD=...
cd ci/docker
./build.sh <directory with Dockerfile>
You will see in stdout:
Image <image id> tagged as <docker registry>/android/image-builder:<tag>
Continue to further publishing:
# Docker registry to publish
export DOCKER_REGISTRY=...
export DOCKER_REGISTRY_USERNAME=...
export DOCKER_REGISTRY_PASSWORD=...
# DockerHub credentials (optional)
export DOCKER_HUB_USERNAME=...
export DOCKER_HUB_PASSWORD=...
cd ci/docker
./publish.sh <directory with Dockerfile>
You will see in stdout:
Published the image <docker registry>/android/builder:<tag>
- Update image hash in
IMAGE_ANDROID_BUILDERvariable in ci shell scripts:- In GitHub repo:
ci/_environment.sh - In internal avito repository:
ci/_main.sh
- In GitHub repo:
- Check this images is working. At least, run
ci/local_check.sh. - Make PR with a new image.
How to prepare ndk archive#
via TeamCity job: Prepare ndk archive (internal)
OR Manually:
- Download ndk for linux
- If you are using MacOS make sure you are working in volume with case-sensitive file system. Create new volume using "Disk Utility" and copy archive there if you don't have case-sensitive volume.
- Unpack zip archive using
unzip <zip file>command in terminal to verify that archive is fully unpacked. Do not use double-click. If you see replace prompt, check previous step. - Change file structure to
ndk/<version>/<ndk files> - Create zip archive using
ziptool with-ry9flags
For example for 25.2.9519653 do:
unzip android-ndk-r25c-linux.zip;
mv android-ndk-r25c 25.2.9519653;
mkdir ndk;
mv 25.2.9519653 ndk/25.2.9519653;
zip -ry9 ndk-linux-25_2_9519653.zip ndk;
How to prepare android-builder for a new compileSdk#
The process of updating the android-builder image consists of three main steps:
- preparing dependencies
- building the image
- and updating the image in the project.
Image types#
- Hermetic — uses pre-packaged archives from Artifactory
- Non-hermetic — downloads SDK components directly from Google repositories
Step 1: Preparing Android SDK dependencies#
Before updating the image, upload new versions of Android SDK components to Artifactory.
Required components:
- platforms (e.g., 36.0.2 for API 36)
- build-tools (may be required to update AGP)
Optional components
platform-tools, cmdline-tools, cmake, and ndk are usually not required to update compileSdk.
You may update them to current versions if desired, or if it's eventually required for newer compileSdk.
Also, make sure that the new versions don’t slow down builds.
Automated method (recommended)#
Use the ready-made scripts in TeamCity (internal)
Or invoke them manually from the repository (internal)
Manual method#
If automated scripts are unavailable:
-
Check available packages via Android SDK Manager:
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --list -
Download required components via Android SDK Manager:
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'platforms;android-36' $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'build-tools;36.0.0' -
Create archives with the correct structure:
See examples of ready archives in Artifactory.
Pack the downloaded components with the same archive structure.cd $ANDROID_HOME zip -r platforms_36_0_2.zip platforms/android-36/ -
Upload the archives to Artifactory.
Step 2: Updating the android-builder image#
Hermetic image#
Edit ./ci/docker/android-builder/hermetic/Dockerfile:
# Update archive versions
RUN unzip_from_url.sh ${ANDROID_SDK_BASE_URL}/platforms/platforms_36_0_2.zip $ANDROID_HOME
Non-hermetic image#
Update ./ci/docker/android-builder/non-hermetic/packages.txt:
build-tools;36.0.0
platforms;android-36
tools
extras;google;google_play_services
extras;google;m2repository
ndk;25.2.9519653
cmake;3.22.1