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 --env ANDROID_EMULATOR_EXTRA_ARGS="-skin 480x800" 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 make automatic detection of this AVD possible, you will need to install socat first: apt-get install socat. Then just run this command to connect your local 5555 port to the container:

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

This is a reversed version of script used to publish AVD's ports. While socat is running, your ADB server will be able to detect 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