Dockerized development environment for Android apps in Kotlin with Jetpack Compose, built with Gradle.
./project.sh start # build the image, download the SDK, generate, build and install the app in the emulator
./project.sh clean # remove the containers, images, volumes and all files here, after asking (--force: without)
The host needs /dev/kvm (hardware virtualization enabled) for the emulator, and mate-terminal, in which the emulator is started.
./project.sh start:
- generates
docker-compose.yml(on GNU/Linux with your user and group id, so generated files are owned by you) - on the first run downloads into
sdk/: the Android command-line tools, Gradle and the Kotlin compiler (CMDLINE_TOOLS_VERSION,GRADLE_VERSION,KOTLIN_VERSIONinproject.sh), and withsdkmanagerthe build tools, platform tools, CMake, NDK, emulator, theandroid-36platform and theSYSTEM_IMAGEsystem image. It then creates an Android virtual device named1. - creates the app in
app/withgradle initif it does not exist yet and replaces the generated files with an Android app (org.example) that shows "Hello world!" - starts the emulator in a new
mate-terminalwindow, then builds the app withgradlew build, installs it withgradlew installDebugand starts it withadb
GRADLE_VERSION in project.sh must match GRADLE_HOME and PATH in Dockerfile.
Based on debian:13.8 with default-jdk, QEMU, android-udev-rules and the X11, sound and GPU libraries the emulator needs. The container uses the host's network and gets /dev/kvm and /dev/snd.
A shell in the container, with this directory as the home directory:
docker compose run --rm android bash
docker-compose.yml is generated on the first run and passes the host's GPU to the android container if one exists:
- Intel and AMD (Mesa):
/dev/driis mapped into the container. On laptops with an additional AMD GPU,DRI_PRIMEselects it. - NVIDIA (proprietary driver): requires the NVIDIA Container Toolkit on the host. The GPU is reserved for the container and selected for OpenGL and Vulkan, also on laptops with PRIME render offload. Without the toolkit,
project.shprints a warning and the container falls back to the other GPU or to software rendering.
Windows use the host's X server (DISPLAY, /tmp/.X11-unix and the X authority file, $XAUTHORITY or else ~/.Xauthority, mounted at the same path) and sound the host's PipeWire/PulseAudio (/run/user/<uid>). docker compose reads DISPLAY and XAUTHORITY each time it starts the container, so the file keeps working after you log in again. The X authority file, /etc/machine-id, /dev/dri and /dev/snd are mounted only if they exist on the host.
The file is not regenerated, so delete docker-compose.yml after adding or removing a GPU or installing the toolkit.
The Android Open Source Project is free and open-source software released mostly under the Apache License 2.0. The prebuilt Android SDK packages that sdkmanager downloads are covered by the Android Software Development Kit License Agreement, which project.sh accepts for you with sdkmanager --licenses, so read it before using this environment. Kotlin is released under the Apache License 2.0.