Public | Automated Build

Last pushed: 7 days ago
Short Description
Headless Android x86 emulator ready for automated instrumentation testing.
Full Description

Android Virtual Device for Docker

This image contains the latest version of Android SDK with configured AVD.


docker run -it --device /dev/kvm -p 5554:5554 -p 5555:5555 thedrhax/android-avd

The --device /dev/kvm flag is required to enable CPU hardware acceleration.
You may also need to activate kvm kernel module on your host machine: modprobe kvm, or even install it first.

Connecting to AVD from other containers/computers

  • adb connect or adb connect IP_OF_AVD_CONTAINER
  • adb devices or adb shell

AVD detection in Gradle, Android Studio, etc.

To enable autodection of this AVD, you will need to install socat first: apt-get install socat. Then just run this command to connect your local 5555 port to the AVD container:

socat tcp-listen:5555,bind=,fork tcp:IP_OF_AVD_CONTAINER:5555

This is a reversed solution used earlier to publish AVD's ports to the public. While socat is running, your ADB server will be able to detect the AVD automatically (just like any Android device connected via USB).

Automatic instrumentation testing example:

# Start socat in the background and remember PID of this process
socat tcp-listen:5555,bind=,fork tcp:IP_OF_AVD_CONTAINER:5555 &

# Run automated instrumentation tests with Gradle
gradle connectedAndroidTest

# Kill socat process
kill $PID
Docker Pull Command
Source Repository

Comments (0)