Android Studio in a Docker container
Last time the repository was tested was in Debian Jessie with Docker version 17.05.0-ce, build 89658be, installed from https://apt.dockerproject.org/repo.
Version 0.3 updates
- The image is based upon Ubuntu 18.04 instead of Ubuntu 14.04.
- Android Studio is now started from a script which optionally keeps the Docker container running after closing Android Studio when it is necessary to exit Android Studio for upgrading it.
- The Cordova support is currently broken. I will fix it when I have the time and/or need for it.
How to keep the Docker container running for upgrading Android Studio
docker exec -it android-studio /bin/bash
- Outside of the container:
touch androidprojects/upgrade(or alternatively
touch /projects/upgradeinside the container).
- Exit Android Studio.
- Run the Android Studio upgrade script.
ps axand find the PID of the process running
tail -f /dev/null
kill $PIDto kill the above process. This will cause the container to exit.
- Next time you restart the container, you'll run the new version of Android Studio.
Two Docker Images
The scripts in the repository now build two Docker images. One is for running Android Studio, and the other - for running Android Cordova builds.
- Clone or unzip the repository into your computer.
- Download Android Studio for Linux from http://developer.android.com/sdk/index.html and save it somewhere.
./build_androidstudio_image.sh yourzipfilesdirectory/android-studio-ide-*-linux.zip; when asked for image name, enter tddpirate/androidstudio:1.3 if you want to build also the Android Cordova image.
- The build_androidstudio_image.sh script auto-detects your uid/gid and the gids of
kvmin your host system. You have the option of selecting different uid/gid for the developer.
- When the image build completes, a container (whose default name is android-studio) is started from it and it starts the Android Studio environment.
- Ensure that the libvirtd daemon is running, for example by using
sudo systemctl enable libvirtd
- When you exit the Android Studio, the container stops execution.
- You can restart the container with
- Ensure that you have the rules in ./51-android.rules also defined also in your host system's /etc/udev/rules.d - you may accomplish this by
sudo cat ./51-android.rules >> /etc/udev/rules.d/51-android.rules
Building the Android Cordova container
If you want to build the Android Cordova container:
- Exit the Android Studio, closing the android-studio container.
cd androiddocker/androiddockerif you are not already at the correct directory.
- When the image build completes, a container (whose default name is android-cordova) is started from it and provides you with a command line where you run the various
You can restart the container with
- The containers created from the image, built from the scripts in this repository, are meant to run only on the same machine on which the image was built. This is contrary to the general Docker philosophy.
- The image was designed to access the Android Studio and your project files from mounted host system directories, rather than keep them inside it. This way, you can upgrade the Android Studio without having to freeze the image, and use your favorite editor to edit your project files from the host system.
To be fixed in the future
- The script for building the tddpirate/androidcordova image currently expects the tddpirate/androidstudio image to have the tag 1.3. It will be fixed in the future if there is enough demand for the fix.
- After exiting the android-cordova container, you need to manually stop it with
docker stop android-cordova.
Thanks to @opyate for his work on testing the scripts and giving feedback.