Skip to content

Instantly share code, notes, and snippets.

@BruceWind
Last active January 29, 2024 11:03
Show Gist options
  • Save BruceWind/2cb94248ac3f9da26b8093e81dc37e94 to your computer and use it in GitHub Desktop.
Save BruceWind/2cb94248ac3f9da26b8093e81dc37e94 to your computer and use it in GitHub Desktop.
You may have a need of emulator in order to run AndroidTes with CI or other. To meet the needs, I start up an Android emulator with docker.
  1. preparation:
  1. run the command:
docker run -d \
  --network=host \
  -e ADBKEY="$(cat ~/.android/adbkey)" \
  --device /dev/kvm \
  --cpus="4" \
  --publish 8554:8554/tcp \
  --publish 5555:5555/tcp  \
  --name android-emulator-30 \
  us-docker.pkg.dev/android-emulator-268719/images/30-google-x64:30.1.2
  adb connect localhost:5555
  adb wait-for-device
  1. and then, enjoy it.

In addition

  • a. How stop and start?
docker container stop android-emulator-30
docker container start android-emulator-30
  • b. how to oversee the device's screen?

as soon as your emulator started,you can use scrcpy to oversee it in terminal.

scrcpy --max-fps 15
  1. bugs

If you encouter problem: adb: error: stat failed when trying to push to /data/local/tmp/scrcpy-server.jar: Permission denied or not a directory, you can try steps below to fix them.

a. run command adb reboot b. try to run scrcpy --max-fps 15 when system just started. You may need to run it many times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment