Skip to content

Commit 056c2e5

Browse files
author
Iain Connor
committed
Working docker image
1 parent 19cd656 commit 056c2e5

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

Dockerfile

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ ENV DEBIAN_FRONTEND noninteractive
1111
ENV VERSION_SDK_TOOLS "25.1.7"
1212
ENV VERSION_BUILD_TOOLS "24.0.2"
1313
ENV VERSION_TARGET_SDK "24"
14+
ENV VERSION_EMULATOR_GOOGLE_APIS_TARGET_SDK "23"
15+
# There's no 24 emulator with Google APIs yet.
1416

1517
ENV ANDROID_HOME "/sdk"
1618
ENV PATH "$PATH:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools"
@@ -32,7 +34,7 @@ RUN apt-get -qq update && \
3234
build-essential \
3335
expect \
3436
file \
35-
libmagic1
37+
libmagic1 \
3638
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3739

3840
# Fix certificates
@@ -54,29 +56,44 @@ RUN chmod +x /usr/local/bin/tools/wait-for-emulator.sh
5456

5557
# And use them to install Android dependencies
5658

57-
RUN ["/opt/tools/android-accept-licenses.sh", "android update sdk --all --no-ui --filter \
58-
platform-tools, \
59-
android-${VERSION_TARGET_SDK}, \
60-
build-tools-${VERSION_BUILD_TOOLS}, \
61-
sys-img-armeabi-v7a-google_apis-${VERSION_TARGET_SDK}, \
62-
extra-android-m2repository, \
63-
extra-google-m2repository, \
64-
extra-android-support, \
65-
extra-google-google_play_services"]
59+
RUN /usr/local/bin/tools/agree-to-licenses.sh \
60+
"android update sdk --all --no-ui --filter platform-tools,android-${VERSION_TARGET_SDK},android-${VERSION_EMULATOR_GOOGLE_APIS_TARGET_SDK},build-tools-${VERSION_BUILD_TOOLS},sys-img-armeabi-v7a-android-${VERSION_TARGET_SDK},sys-img-armeabi-v7a-google_apis-${VERSION_EMULATOR_GOOGLE_APIS_TARGET_SDK},extra-android-support,extra-android-m2repository,extra-google-m2repository,extra-google-google_play_services"
6661

67-
# Create emulator
62+
# Create emulators
6863

64+
RUN android list targets
65+
66+
# Without Google APIs
6967
RUN echo "no" | android create avd \
7068
--force \
7169
--device "Nexus 5" \
7270
--name nexus5_${VERSION_TARGET_SDK} \
7371
--target android-${VERSION_TARGET_SDK} \
72+
--abi default/armeabi-v7a \
73+
--skin WVGA800 \
74+
--sdcard 512M
75+
76+
# With Google APIs
77+
RUN echo "no" | android create avd \
78+
--force \
79+
--device "Nexus 5" \
80+
--name nexus5_${VERSION_EMULATOR_GOOGLE_APIS_TARGET_SDK} \
81+
--target android-${VERSION_EMULATOR_GOOGLE_APIS_TARGET_SDK} \
7482
--abi google_apis/armeabi-v7a \
7583
--skin WVGA800 \
7684
--sdcard 512M
7785

78-
# Boot up the emulator
86+
# Boot up the emulators
87+
88+
# Without Google APIs
89+
RUN /bin/bash -c "SHELL=/bin/bash emulator -avd nexus5_${VERSION_TARGET_SDK} -no-skin -no-audio -no-window & \
90+
adb wait-for-device && \
91+
/usr/local/bin/tools/wait-for-emulator.sh" && \
92+
adb -s emulator-5554 emu kill
93+
7994

80-
RUN ["/bin/bash", "-c", "SHELL=/bin/bash emulator -avd nexus5_${VERSION_TARGET_SDK} -no-skin -no-audio -no-window & /usr/local/bin/tools/wait-for-emulator.sh"]
81-
RUN adb wait-for-device
82-
RUN android-start-emulator nexus5_${VERSION_TARGET_SDK} && adb -s emulator-5554 emu kill
95+
# With Google APIs
96+
RUN /bin/bash -c "SHELL=/bin/bash emulator -avd nexus5_${VERSION_EMULATOR_GOOGLE_APIS_TARGET_SDK} -no-skin -no-audio -no-window & \
97+
adb wait-for-device && \
98+
/usr/local/bin/tools/wait-for-emulator.sh" && \
99+
adb -s emulator-5554 emu kill

tools/agree-to-licenses.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/expect -f
22

33
set timeout 1800
44
set cmd [lindex $argv 0]
5-
set licenses [lindex $argv 1]
65

76
spawn {*}$cmd
87
expect {

tools/wait-for-emulator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ until [[ "$bootanim" =~ "stopped" ]]; do
1111
if [[ "$bootanim" =~ "device not found" || "$bootanim" =~ "device offline"
1212
|| "$bootanim" =~ "running" ]]; then
1313
let "failcounter += 1"
14-
echo "Waiting for emulator to start"
14+
echo "Waiting for emulator to start [$failcounter / $timeout_in_sec]"
1515
if [[ $failcounter -gt timeout_in_sec ]]; then
1616
echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator"
1717
exit 1

0 commit comments

Comments
 (0)