Sign inSign up

cndaqiang/docker-android-emulator

By cndaqiang

•Updated almost 2 years ago

🤖 A minimal and customizable Docker image running the Android emulator as a service.

Image
Developer tools
0

1.1K

cndaqiang/docker-android-emulator repository overview

⁠Docker Android Emulator

Docker Image CI DeepSource Docker Pulls

This repository contains Docker images for building Android emulator. The images are based on HQarroum/docker-android⁠ and have been forked and modified to better suit my needs. The modified version can be found at cndaqiang/docker-android-emulator⁠.

You can pull the Docker image from Docker Hub:cndaqiang/docker-android-emulator⁠.

⁠Modifications

This fork includes the following modifications:

  • -e PARTITION=16384:
    • Meaning: Sets the environment variable PARTITION to 16384.
    • Description: This environment variable is typically used to specify the partition size for the emulator. In Android emulators, the partition size determines the storage capacity of the virtual device (in MB). 16384 represents a partition size of 16GB. This value will affect the amount of storage available within the virtual device, such as for app installations and data storage.
  • EMULATOR_ARGS:
    • Meaning: A string containing any additional arguments you want to pass to the emulator.
    • Description: This environment variable allows you to specify custom parameters when starting the emulator. For example:
      • -timezone Asia/Shanghai

The emulator is started with the following command, which incorporates both default and custom parameters:

emulator \
  -avd android \
  -gpu "$GPU_MODE" \
  -memory $OPT_MEMORY \
  -partition-size $PARTITION \
  -no-boot-anim \
  -cores $OPT_CORES \
  -ranchu \
  $AUTH_FLAG \
  -no-window \
  -no-snapshot  \
  $EMULATOR_ARGS || update_state "ANDROID_STOPPED"

⁠Why ARM64 is not supported:

Currently, on ARM64 devices, the sdkmanager does not include the emulator component, making it impossible to create an emulator image on such platforms. As a result, this container can only be run on amd64 platforms. More See build.arm64.faild⁠

Additionally, the ARM64 emulator support is not available because the QEMU2 emulator does not support the ARM64 CPU architecture on an x86_64 host. This limitation prevents the use of the Android emulator for ARM64 images, even on systems that support ARM64-based containers.

For ARM64 devices, we provide only a minimal version of the image that excludes the Android SDK and emulator, useful primarily as a base image for other purposes.

⁠Credits

This project is a fork of HQarroum/docker-android⁠. I would like to thank the original author for providing a great foundation and the base Dockerfiles that made it possible to easily create these custom Android environments.

⁠Example:

docker run -d --device /dev/kvm -p 5555:5555 -v androiddata:/data -e PARTITION=24576 -e MEMORY=6144 -e CORES=2 --name docker-android-emulator cndaqiang/docker-android-emulator:api-33

⁠Debug:

docker stop docker-android-emulator; docker volume rm androiddata
docker run -d --rm --device /dev/kvm -p 5555:5555 -v androiddata:/data -e PARTITION=24576 -e EMULATOR_ARGS="-timezone Asia/Shanghai" -e MEMORY=6144 -e CORES=4 --name docker-android-emulator cndaqiang/docker-android-emulator:api-33 
docker run -it --rm --device /dev/kvm --entrypoint /bin/bash -p 5555:5555 -v androiddata:/data -e PARTITION=24576 -e EMULATOR_ARGS="-timezone Asia/Shanghai" -e MEMORY=6144 -e CORES=4 --name docker-android-emulator cndaqiang/docker-android-emulator:api-33 

# my mod version
docker stop docker-android; docker volume rm data
docker run -d --rm --device /dev/kvm -p 5555:5555 -v data:/data -e PARTITION=24576 -e EMULATOR_ARGS="-timezone Asia/Shanghai" -e MEMORY=6144 -e CORES=4 --name docker-android cndaqiang/docker-android:api-33
#

api-33arm64v8a

PANIC: Avd's CPU Architecture 'arm64' is not supported by the QEMU2 emulator on x86_64 host.

api-27/25arm64v8a

PANIC: QEMU2 emulator does not support arm64 CPU architecture{ "type": "state-update", "value": "ANDROID_STOPPED" }
docker pull cndaqiang/docker-android-emulator:api-27arm64v8a

docker run -it --rm  --entrypoint /bin/bash  --device /dev/kvm -p 5555:5555 -v androiddata:/data -e PARTITION=24576 -e EMULATOR_ARGS="-timezone Asia/Shanghai" -e MEMORY=6144 -e CORES=4 --name docker-android-emulator cndaqiang/docker-android-emulator:api-27arm64v8a
docker run -it --rm --device /dev/kvm -p 5555:5555 -v androiddata:/data -e PARTITION=24576 -e EMULATOR_ARGS="-timezone Asia/Shanghai  -no-accel -no-window -no-audio -no-boot-anim" -e MEMORY=6144 -e CORES=4 --name docker-android-emulator cndaqiang/docker-android-emulator:api-27arm64v8a

Tag summary

Content type

Image

Digest

sha256:12dedff50…

Size

1.7 GB

Last updated

almost 2 years ago

docker pull cndaqiang/docker-android-emulator:api-25arm64v8a