@@ -16,14 +16,14 @@ docker-emulator-android is one of the components of [android-farm](https://githu
|
|||||||
# Usage
|
# Usage
|
||||||
For example to run default emulator options with Marshmallow (API 23):
|
For example to run default emulator options with Marshmallow (API 23):
|
||||||
```console
|
```console
|
||||||
$ docker run --rm --privileged -e ANDROID_ARCH="x86" -v /dev/kvm:/dev/kvm agoda-com/docker-emulator-android-23:latest
|
$ docker run --rm --privileged -e ANDROID_ARCH="x86_64" -v /dev/kvm:/dev/kvm agoda-com/docker-emulator-android-23:latest
|
||||||
$ adb connect VIP:5555
|
$ adb connect VIP:5555
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to start different configuration of device, for example a 7 inch tablet, you need to override `config.ini` variables:
|
If you want to start different configuration of device, for example a 7 inch tablet, you need to override `config.ini` variables:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ docker run --rm --privileged -e ANDROID_ARCH="x86" -e ANDROID_CONFIG="skin.name=600x1024;hw.lcd.density=160;hw.lcd.height=600;hw.lcd.width=1024;hw.device.name=7in WSVGA (Tablet);avd.ini.displayname=7 WSVGA (Tablet) API 23;" -v /dev/kvm:/dev/kvm agoda-com/docker-emulator-android-23:latest
|
$ docker run --rm --privileged -e ANDROID_ARCH="x86_64" -e ANDROID_CONFIG="skin.name=600x1024;hw.lcd.density=160;hw.lcd.height=600;hw.lcd.width=1024;hw.device.name=7in WSVGA (Tablet);avd.ini.displayname=7 WSVGA (Tablet) API 23;" -v /dev/kvm:/dev/kvm agoda-com/docker-emulator-android-23:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
For all the options available please check the [official documentation](https://developer.android.com/studio/run/emulator-commandline.html)
|
For all the options available please check the [official documentation](https://developer.android.com/studio/run/emulator-commandline.html)
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ RUN dpkg --add-architecture i386 && \
|
|||||||
apt-get update && \
|
apt-get update && \
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -yq software-properties-common libstdc++6:i386 zlib1g:i386 libncurses5:i386 \
|
DEBIAN_FRONTEND=noninteractive apt-get install -yq software-properties-common libstdc++6:i386 zlib1g:i386 libncurses5:i386 \
|
||||||
locales ca-certificates apt-transport-https curl unzip redir iproute2 \
|
locales ca-certificates apt-transport-https curl unzip redir iproute2 \
|
||||||
openjdk-8-jdk xvfb x11vnc fluxbox nano libpulse0 telnet expect\
|
openjdk-8-jdk xvfb x11vnc fluxbox nano telnet expect \
|
||||||
|
libc6 libdbus-1-3 libfontconfig1 libgcc1 \
|
||||||
|
libpulse0 libtinfo5 libx11-6 libxcb1 libxdamage1 \
|
||||||
|
libnss3 libxcomposite1 libxcursor1 libxi6 \
|
||||||
|
libxext6 libxfixes3 zlib1g libgl1 pulseaudio socat \
|
||||||
--no-install-recommends && \
|
--no-install-recommends && \
|
||||||
locale-gen en_US.UTF-8 && \
|
locale-gen en_US.UTF-8 && \
|
||||||
# Install Android SDK
|
# Install Android SDK
|
||||||
@@ -29,30 +33,30 @@ RUN dpkg --add-architecture i386 && \
|
|||||||
rm /tmp/android-sdk-linux.zip && \
|
rm /tmp/android-sdk-linux.zip && \
|
||||||
# Customized steps per specific platform
|
# Customized steps per specific platform
|
||||||
yes | sdkmanager --no_https --licenses && \
|
yes | sdkmanager --no_https --licenses && \
|
||||||
yes | sdkmanager emulator tools platform-tools "platforms;{{ platform }}" "system-images;{{ platform }};google_apis;x86" --verbose | uniq && \
|
yes | sdkmanager emulator tools platform-tools "platforms;{{ platform }}" "system-images;{{ platform }};google_apis;x86_64" --verbose | uniq && \
|
||||||
echo no | avdmanager create avd -n "x86" --package "system-images;{{ platform }};google_apis;x86" --tag google_apis && \
|
echo no | avdmanager create avd -n "Pixel2" --package "system-images;{{ platform }};google_apis;x86_64" --tag google_apis && \
|
||||||
# Unfilter devices (now local because CI downloads from github are unstable)
|
# Unfilter devices (now local because CI downloads from github are unstable)
|
||||||
# curl -o /root/.android/adb_usb.ini https://raw.githubusercontent.com/apkudo/adbusbini/master/adb_usb.ini && \
|
# curl -o /root/.android/adb_usb.ini https://raw.githubusercontent.com/apkudo/adbusbini/master/adb_usb.ini && \
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get purge -yq unzip openjdk-8-jdk && \
|
DEBIAN_FRONTEND=noninteractive apt-get purge -yq unzip openjdk-8-jdk && \
|
||||||
# Convert large partitions to qcow2 to save space
|
|
||||||
qemu-img convert -O qcow2 -c /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/system.img /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/system.qcow2 && \
|
|
||||||
mv /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/system.qcow2 /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/system.img && \
|
|
||||||
qemu-img convert -O qcow2 -c /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/userdata.img /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/userdata.qcow2 && \
|
|
||||||
mv /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/userdata.qcow2 /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/userdata.img && \
|
|
||||||
qemu-img resize /root/.android/avd/x86.avd/userdata.img 2G && \
|
|
||||||
e2fsck -fy /root/.android/avd/x86.avd/userdata.img && \
|
|
||||||
resize2fs /root/.android/avd/x86.avd/userdata.img && \
|
|
||||||
qemu-img convert -O qcow2 -c /root/.android/avd/x86.avd/userdata.img /root/.android/avd/x86.avd/userdata.qcow2 && \
|
|
||||||
mv /root/.android/avd/x86.avd/userdata.qcow2 /root/.android/avd/x86.avd/userdata.img && \
|
|
||||||
(qemu-img convert -O qcow2 -c /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/vendor.img /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/vendor.qcow2 && \
|
|
||||||
mv /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/vendor.qcow2 /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/vendor.img || true) && \
|
|
||||||
# Clean up
|
# Clean up
|
||||||
apt-get -yq autoremove && \
|
apt-get -yq autoremove && \
|
||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
apt-get autoclean && \
|
apt-get autoclean && \
|
||||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
COPY config.ini /root/.android/avd/x86.avd/config.ini
|
# Convert large partitions to qcow2 to save space
|
||||||
|
# RUN qemu-img convert -O qcow2 -c /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/system.img /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/system.qcow2 && \
|
||||||
|
# mv /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/system.qcow2 /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/system.img && \
|
||||||
|
# qemu-img convert -O qcow2 -c /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/userdata.img /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/userdata.qcow2 && \
|
||||||
|
# mv /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/userdata.qcow2 /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/userdata.img && \
|
||||||
|
# qemu-img resize /root/.android/avd/Pixel2.avd/userdata.img 2G && \
|
||||||
|
# resize2fs /root/.android/avd/Pixel2.avd/userdata.img && \
|
||||||
|
# qemu-img convert -O qcow2 -c /root/.android/avd/Pixel2.avd/userdata.img /root/.android/avd/Pixel2.avd/userdata.qcow2 && \
|
||||||
|
# mv /root/.android/avd/Pixel2.avd/userdata.qcow2 /root/.android/avd/Pixel2.avd/userdata.img && \
|
||||||
|
# (qemu-img convert -O qcow2 -c /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/vendor.img /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/vendor.qcow2 && \
|
||||||
|
# mv /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/vendor.qcow2 /opt/android-sdk-linux/system-images/{{ platform }}/google_apis/x86/vendor.img || true)
|
||||||
|
|
||||||
|
COPY config.ini /root/.android/avd/Pixel2.avd/config.ini
|
||||||
|
|
||||||
# Expose adb
|
# Expose adb
|
||||||
EXPOSE 5037 5554 5555 5900
|
EXPOSE 5037 5554 5555 5900
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
OWNER=agoda
|
OWNER=mobdevops/agoda
|
||||||
IMAGE_NAME=docker-emulator-{{ platform }}
|
IMAGE_NAME=docker-emulator-{{ platform }}
|
||||||
VCS_REF=`git rev-parse --short HEAD`
|
VCS_REF=`git rev-parse --short HEAD`
|
||||||
IMAGE_VERSION ?= 1.0.0
|
IMAGE_VERSION ?= 1.0.0
|
||||||
|
|||||||
@@ -1,39 +1,51 @@
|
|||||||
avd.ini.encoding=UTF-8
|
AvdId=Pixel2
|
||||||
AvdId=x86
|
|
||||||
PlayStore.enabled=true
|
PlayStore.enabled=true
|
||||||
abi.type=x86
|
avd.ini.displayname=Pixel2
|
||||||
avd.ini.displayname=x86
|
avd.ini.encoding=UTF-8
|
||||||
disk.dataPartition.size=800M
|
# Real Pixel2 ships with 32GB
|
||||||
|
disk.dataPartition.size=2048M
|
||||||
|
fastboot.forceColdBoot=no
|
||||||
hw.accelerometer=yes
|
hw.accelerometer=yes
|
||||||
hw.audioInput=no
|
hw.audioInput=yes
|
||||||
hw.battery=yes
|
hw.battery=yes
|
||||||
hw.camera.back=none
|
hw.camera.back=none # 'emulated' by default
|
||||||
hw.camera.front=none
|
hw.camera.front=none # 'emulated' by default
|
||||||
hw.cpu.arch=x86
|
hw.cpu.ncore=4
|
||||||
hw.cpu.ncore=2
|
|
||||||
hw.dPad=no
|
hw.dPad=no
|
||||||
hw.device.hash2=MD5:1be89bc42ec9644d4b77968b23474980
|
hw.device.hash2=MD5:1be89bc42ec9644d4b77968b23474980
|
||||||
hw.device.manufacturer=Google
|
hw.device.manufacturer=Google
|
||||||
hw.device.name=Nexus 5X
|
|
||||||
hw.gps=yes
|
hw.gps=yes
|
||||||
hw.gpu.enabled=on
|
hw.gpu.enabled=yes
|
||||||
hw.gpu.mode=swiftshader_indirect
|
hw.gpu.mode=swiftshader_indirect
|
||||||
hw.initialOrientation=Portrait
|
hw.initialOrientation=Portrait
|
||||||
hw.keyboard=no
|
hw.keyboard=yes
|
||||||
hw.lcd.density=160
|
|
||||||
hw.mainKeys=no
|
hw.mainKeys=no
|
||||||
hw.ramSize=1536
|
hw.ramSize=4096
|
||||||
hw.sensors.orientation=yes
|
hw.sensors.orientation=yes
|
||||||
hw.sensors.proximity=yes
|
hw.sensors.proximity=yes
|
||||||
hw.trackBall=no
|
hw.trackBall=no
|
||||||
image.sysdir.1=system-images/{{ platform }}/google_apis/x86/
|
|
||||||
runtime.network.latency=none
|
runtime.network.latency=none
|
||||||
runtime.network.speed=full
|
runtime.network.speed=full
|
||||||
|
vm.heapSize=512
|
||||||
|
tag.display=Google APIs
|
||||||
|
# Set some
|
||||||
|
hw.lcd.density=160 # '440' by default
|
||||||
|
hw.lcd.height=800 # '1920' by default
|
||||||
|
hw.lcd.width=480 # '1080' by default
|
||||||
|
# Unused
|
||||||
|
# hw.sdCard=yes
|
||||||
|
# sdcard.size=512M
|
||||||
|
|
||||||
|
tag.id=google_apis
|
||||||
|
abi.type=x86_64
|
||||||
|
hw.cpu.arch=x86_64
|
||||||
|
image.sysdir.1=system-images/{{ platform }}/google_apis/x86_64/
|
||||||
|
|
||||||
|
# End of default configuration
|
||||||
|
|
||||||
|
hw.device.name=Pixel2
|
||||||
showDeviceFrame=no
|
showDeviceFrame=no
|
||||||
skin.dynamic=yes
|
skin.dynamic=yes
|
||||||
skin.name=480x800
|
skin.name=480x800
|
||||||
skin.path=_no_skin
|
skin.path=_no_skin
|
||||||
skin.path.backup=_no_skin
|
skin.path.backup=_no_skin
|
||||||
tag.display=Google APIs
|
|
||||||
tag.id=google_apis
|
|
||||||
vm.heapSize=192
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Xvfb :1 +extension GLX +extension RANDR +extension RENDER +extension XFIXES -scr
|
|||||||
XVFB_PID=$!
|
XVFB_PID=$!
|
||||||
|
|
||||||
cd /opt/android-sdk-linux/emulator
|
cd /opt/android-sdk-linux/emulator
|
||||||
LIBGL_DEBUG=verbose ./qemu/linux-x86_64/qemu-system-x86_64 -avd x86 -snapshot default -no-snapshot-save &
|
LIBGL_DEBUG=verbose ./qemu/linux-x86_64/qemu-system-x86_64 -avd Pixel2 -snapshot default -no-snapshot-save &
|
||||||
EMULATOR_PID=$!
|
EMULATOR_PID=$!
|
||||||
|
|
||||||
adb wait-for-device
|
adb wait-for-device
|
||||||
@@ -45,8 +45,8 @@ save
|
|||||||
adb emu kill
|
adb emu kill
|
||||||
|
|
||||||
# Doesn't work: triggers cold boot
|
# Doesn't work: triggers cold boot
|
||||||
# qemu-img convert -O qcow2 -c /root/.android/avd/x86.avd/userdata-qemu.img /root/.android/avd/x86.avd/userdata-qemu.img_qcow2
|
# qemu-img convert -O qcow2 -c /root/.android/avd/Pixel2.avd/userdata-qemu.img /root/.android/avd/Pixel2.avd/userdata-qemu.img_qcow2
|
||||||
# mv /root/.android/avd/x86.avd/userdata-qemu.img_qcow2 /root/.android/avd/x86.avd/userdata-qemu.img
|
# mv /root/.android/avd/Pixel2.avd/userdata-qemu.img_qcow2 /root/.android/avd/Pixel2.avd/userdata-qemu.img
|
||||||
|
|
||||||
# Moving adb binary away so that stopping adb server with delay will release the emulator and will make it available for external connections
|
# Moving adb binary away so that stopping adb server with delay will release the emulator and will make it available for external connections
|
||||||
mv /opt/android-sdk-linux/platform-tools/adb /opt/android-sdk-linux/platform-tools/_adb
|
mv /opt/android-sdk-linux/platform-tools/adb /opt/android-sdk-linux/platform-tools/_adb
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ VNC_PID=$!
|
|||||||
# qemu references bios by relative path
|
# qemu references bios by relative path
|
||||||
cd /opt/android-sdk-linux/emulator
|
cd /opt/android-sdk-linux/emulator
|
||||||
|
|
||||||
CONFIG="/root/.android/avd/x86.avd/config.ini"
|
CONFIG="/root/.android/avd/Pixel2.avd/config.ini"
|
||||||
CONFIGTMP=${CONFIG}.tmp
|
CONFIGTMP=${CONFIG}.tmp
|
||||||
|
|
||||||
if [ -n "$ANDROID_CONFIG" ];
|
if [ -n "$ANDROID_CONFIG" ];
|
||||||
@@ -69,4 +69,4 @@ fi
|
|||||||
|
|
||||||
echo "emulator_opts: $emulator_opts"
|
echo "emulator_opts: $emulator_opts"
|
||||||
|
|
||||||
LIBGL_DEBUG=verbose ./qemu/linux-x86_64/qemu-system-x86_64 -avd x86 -ports $console_port,$adb_port $emulator_opts -qemu $QEMU_OPTS
|
LIBGL_DEBUG=verbose ./qemu/linux-x86_64/qemu-system-x86_64 -avd Pixel2 -ports $console_port,$adb_port $emulator_opts -qemu $QEMU_OPTS
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ snapshot_image_name=$2
|
|||||||
|
|
||||||
docker rm -f emulator || true
|
docker rm -f emulator || true
|
||||||
|
|
||||||
docker run -d -t --name emulator --rm --privileged -v /dev/kvm:/dev/kvm -e ANDROID_ARCH="x86" $image_name bash
|
docker run -d -t --name emulator --rm --privileged -v /dev/kvm:/dev/kvm -e ANDROID_ARCH="x86_64" $image_name bash
|
||||||
|
|
||||||
docker cp snapshot.sh emulator:/snapshot.sh
|
docker cp snapshot.sh emulator:/snapshot.sh
|
||||||
docker cp snapshot.expect emulator:/snapshot.expect
|
docker cp snapshot.expect emulator:/snapshot.expect
|
||||||
|
|||||||
Reference in New Issue
Block a user