bazted / docker-android-avd

Headless Android x86 emulator ready for automated instrumentation testing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android Virtual Device for Docker

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

Example

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 127.0.0.1 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=127.0.0.1,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=127.0.0.1,fork tcp:IP_OF_AVD_CONTAINER:5555 &
PID=$!

# Run automated instrumentation tests with Gradle
gradle connectedAndroidTest

# Kill socat process
kill $PID

About

Headless Android x86 emulator ready for automated instrumentation testing.


Languages

Language:Shell 100.0%