Forked from https://github.com/tracer0tong/android-emulator
Changes:
- Specify 16.04 as base image
- Include only API-25 SDK and its arm image.
- Removed SSH Server
0.0.1
git clone https://github.com/dodoinblue/android-emulator cd android-emulator docker build .
Use Docker registry with latest tag:
$ docker pull netdodo/android-emulator:latest
$ docker run -d -P --name android netdodo/android-emulator
Now a container should be running in the background. Now restart adb-server to connect to the newly launched emulator.
- Find which port is using:
$ docker port android
# Output
5037/tcp -> 0.0.0.0:32784
5554/tcp -> 0.0.0.0:32783
5555/tcp -> 0.0.0.0:32782 #<-- use this port
- Use the port linked with 5555 to start server.
adb kill-server
adb connect 172.17.0.2:32782
If this does not work, use try following:
adb connect 0.0.0.0:32782
$ adb kill-server
$ adb connect 0.0.0.0:32782
If works, you should get messages like these:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
connected to 0.0.0.0:32782
$ adb devices
List of devices attached
0.0.0.0:32782 device
- Now you should be able to run test on this emulator
./gradlew connectedDebugAndroidTest
- Clone android app code to your host machine, say /User/test/test-app
- Start container, mount volume and specify build command. Example:
cd /User/test/test-app
docker run -P -v `pwd`:/workspace -n android bash -c "./gradlew assembleDebug"
- Use emulator and gradle build in same container is not stable. Emulator may be killed for some reason.
- When you build, make sure your source code root does not contain a local.properties file.