Today, with our pre-built Android emulator container, it’s easier than ever to set up and run an Android emulator on a continuous integration and delivery system (CI/CD). These containers make it easy to find and run the correct version of the emulator without the headache of dependency management. It also makes it easier for continuous integration and delivery systems to add automated testing without the expense of maintaining a large number of physical devices.
Early last year, we released Android emulator downloads and scripts generated by Docker images to help developers deploy and debug remote emulators. These scripts simplify the process of finding the correct system image, managing system dependencies, and running the Android emulator.
Now we’ve decided to go one step further and experimentally provide pre-built Android emulator containers for every major emulator update release. These containers no longer require you to run the generator manually, saving both time and complexity. Don’t worry, these pre-built containers still support all the functionality of containers built with Docker scripts, such as ADB and Web accessibility.
To run these containers, Linux KVM is required, and you can start Linux KVM by running it bare-metal or on a virtual machine that supports nested virtualization. The choice depends on your cloud computing provider, see our documentation for advice.
The following script explains how to integrate the Android emulator container into your system and use it to run tests.
#! /bin/bash # This is the remote mirror we are going to run # If necessary, Docker =us-docker.pkg.dev/android-emulator-268719/images/ r-Google-x64:30.0.23 It is best to use a high port so that it does not interfere with the ADB scan emulator. Docker run -d -e "ADBKEY=$(cat ~/.android/ ADBKEY)" --device /dev/kvm --publish \ 8554:8554/tcp --publish $PORT:5555/tcp \ $DOCKER_IMAGE) echo "The container is running with id: $container_id" # failed to connect to localhost: Echo "Connecting to ForwardedADB port." ADB connect localhost:$port # We have to wait until the 'docker ps' is displayed as normal. # This process may take a while because the emulator needs to be fully started! Adb wait-for-device echo "Waiting until the device is ready" adb wait-for-device # We just wait for sys.boot_completed to be set to 1. while [ "`adb shell getprop sys.boot_completed | tr -d '\r' `" != "1" ] ; do echo "Still waiting for boot.." sleep 1; Done # Now you can use the emulator normally, for example: /gradlew installDebug #./gradlew connectedAndroidTest # etc echo "The device is ready" echo "Run The following command to stop the container:" echo "docker stop ${container_id}"Copy the code
Example scripts for image pull, run, and port forwarding of the Android emulator container
To learn more about the Android emulator container, check out README. This is the first time we have offered a pre-built simulator container, so if you find any problems or feature requests while using it, please let us know via Issue Tracker.