Complete Android-Studio in a Docker container.
You can even start an Emulator inside it.
If you don't have a display the Emulator can run with a "dummy" display — perfect for continuous integration.
Tested on Linux only.
Just run:
./build.shor:
docker build -t deadolus/android-studio .An already built version is also on Docker Hub. So you may also run:
docker pull deadolus/android-studioYou may of course change the name of the container.
Run:
HOST_DISPLAY=1 ./run.shor run directly via:
docker run -i $AOSP_ARGS -v `pwd`/studio-data:/studio-data --privileged --group-add plugdev deadolus/android-studiorun.sh has some options which you can set via environment variables:
NO_TTY– Do not run docker with-tflagDOCKERHOSTNAME– Set Docker Hostname. Useful for headless test runsHOST_USB– Use the USB of the Host (e.g., for physical device access viaadb)HOST_NET– Use the network of the hostHOST_DISPLAY– Allow the container to use the host's display (e.g., for running the emulator)
Example usage:
HOST_NET=1 ./run.shThe default Docker entrypoint tries to start Android Studio.
So it probably does not make sense to use run.sh without:
HOST_DISPLAY=1If you just want a shell inside the container without starting Android Studio, run:
./run.sh bash-
Comment/uncomment the appropriate lines in the
compose.yamldepending on whether you're running natively on Linux or in WSL. -
To build:
docker compose build android_emulator
-
To run:
docker compose run android_emulator
A script is included at:
provisioning/ndkTests.shThis demonstrates how to use this container in a CI environment.
If the HOSTNAME variable is set to CI, it starts a headless container, then changes into the directory:
workspace/GoogleTestAppIt builds and installs an app, parses logcat for lines containing the string GoogleTest, uninstalls the app, and analyzes the parsed output.
While this script may not be directly useful for your use case, it serves as a useful guide.