Skip to content

Commit

Permalink
Build tools 25.0.3 (#3)
Browse files Browse the repository at this point in the history
* Change the download step of android sdk to android tools only (most recent)

* Add libqt5widgets5 to the list of install dependencies for emulator

* Change the emulator image to one with google api (#1)

* Update android tools zip  and use new commands (#2)

- Update build-tools, plataform, repositories, etc.

* Change used emulator binary from 64-x86 to normal (#3)

- Add emulator folder path to PATH env var.

* Fix image emulator dependencies and some improves. (#4)

- Change from ubuntu:16.04 to debian:jessie base image.
- Change from openjdk8 to java8
- Fix Qt emulator dependency start failure copying all internal qt libs
to system qt folder.

* Improve wait-for-emulator script and fix emulator resolution (#5)
  • Loading branch information
niltonvasques authored Oct 30, 2017
1 parent 8dd1132 commit 9f8f97d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 35 deletions.
54 changes: 32 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
# This Dockerfile creates a android enviroment prepared to run integration tests
from ubuntu:16.04
from debian:jessie

RUN apt-get update && apt-get install openjdk-8-jdk git wget -y
# Install java 8
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list \
&& echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list \
&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 \
&& echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections \
&& apt-get update && apt-get install oracle-java8-installer oracle-java8-set-default -y

# Install another dependencies
RUN apt-get install git wget unzip gcc-multilib libglu1 -y

#Install Android
RUN wget -qO- https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz --show-progress \
| tar -xz -C /opt/
ENV ANDROID_HOME /opt/android-sdk-linux
ENV PATH $PATH:$ANDROID_HOME/tools
ENV ANDROID_HOME /opt/android
RUN wget -O android-tools.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip --show-progress \
&& unzip android-tools.zip -d $ANDROID_HOME && rm android-tools.zip
ENV PATH $PATH:$ANDROID_HOME/tools/bin

#Install Android Tools
ENV SDK_FILTERS platform-tools,android-23,android-24,build-tools-24.0.3,extra-android-m2repository,extra-google-m2repository
RUN ( sleep 4 && while [ 1 ]; do sleep 1; echo y; done ) \
| android update sdk --no-ui --force -a --filter \ $SDK_FILTERS && android update adb

# Add platform-tools to path
RUN yes | sdkmanager --update --verbose
RUN yes | sdkmanager "platform-tools" --verbose
RUN yes | sdkmanager "platforms;android-25" --verbose
RUN yes | sdkmanager "build-tools;25.0.3" --verbose
RUN yes | sdkmanager "extras;android;m2repository" --verbose
RUN yes | sdkmanager "extras;google;m2repository" --verbose

# Add platform-tools and emulator to path
ENV PATH $PATH:$ANDROID_HOME/platform-tools

#Install latest android tools and system images
RUN echo y | android update sdk --no-ui --force -a --filter sys-img-x86-android-24
ENV PATH $PATH:$ANDROID_HOME/emulator

# Install dependencies to run android tools 32bits binaries
RUN apt-get install gcc-multilib -y
#Install latest android emulator system images
ENV EMULATOR_IMAGE "system-images;android-24;google_apis;x86_64"
RUN yes | sdkmanager $EMULATOR_IMAGE --verbose

# Creating sdcard image
RUN mksdcard -l sdcard 100M sdcard.img
# Copy Qt library files to system folder
RUN cp -a /opt/android/emulator/lib64/qt/lib/. /usr/lib/x86_64-linux-gnu/

# Creating a emulator with sdcard
RUN echo "no" | android create avd -f -n test -t android-24 --abi default/x86 -c sdcard.img
RUN echo "no" | avdmanager -v create avd -n test -k $EMULATOR_IMAGE -c 100M

ADD start_emulator.sh /bin/start_emulator
RUN chmod +x /bin/start_emulator
Expand All @@ -39,6 +49,6 @@ ADD unlock_emulator.sh /bin/unlock_emulator
RUN chmod +x /bin/unlock_emulator

#Label
MAINTAINER Nilton Vasques <[email protected]>
LABEL Version="1.3" \
Description="Android emulator environment"
MAINTAINER Catbag <[email protected]>
LABEL Version="0.1.2" \
Description="Android SDK and emulator environment"
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
## Android Emulator Docker image
## Android SDK and Emulator Docker image

### Usage

* Launch, wait and unlock the emulator

docker run --privileged -v /dev/kvm:/dev/kvm --rm niltonvasques/android-emulator:1.3 \
docker run --privileged -v /dev/kvm:/dev/kvm --rm catbagdev/android-sdk-and-emulator:0.1.0 \
bash -c "start_emulator && wait_emulator && unlock_emulator"
* Using with drone.io CI

* Usage with Drone CI

```yml
build:
image: niltonvasques/android-emulator:1.3
image: catbagdev/android-sdk-and-emulator:0.1.2
privileged: true
commands:
- cp -a /drone/.gradle /root/ && rm -Rf /drone/.gradle
Expand Down
2 changes: 1 addition & 1 deletion start_emulator.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
echo "no" | emulator64-x86 -avd test -noaudio -no-window -gpu off -verbose -qemu -usbdevice tablet &
emulator64-x86 -avd test -noaudio -no-window -skin 480x800 -gpu off -verbose -qemu -usbdevice tablet &
41 changes: 34 additions & 7 deletions wait_emulator_boot.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
#!/bin/bash

adb wait-for-device
A=$(adb shell getprop sys.boot_completed | tr -d '\r');
sec=0;
while [ "$A" != "1" ]; do
echo "waiting emulator boot for "$sec" seconds";
sleep 10;
sec=$((sec + 10));
A=$(adb shell getprop sys.boot_completed | tr -d '\r');

# from https://github.com/travis-ci/travis-cookbooks/blob/master/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
# Originally written by Ralf Kistner <[email protected]>, but placed in the public domain

set +e

bootanim=""
failcounter=0
timeout_in_sec=360

until [[ "$bootanim" =~ "stopped" ]]; do
bootanim=`adb -e shell getprop init.svc.bootanim 2>&1 &`
if [[ "$bootanim" =~ "device not found" || "$bootanim" =~ "device offline"
|| "$bootanim" =~ "running" ]]; then
let "failcounter += 1"
echo "Waiting for emulator to start"
if [[ $failcounter -gt timeout_in_sec ]]; then
echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator"
exit 1
fi
fi
sleep 1
done

# Fail proof way to detect emulator ready status
A=$(adb shell getprop sys.boot_completed | tr -d '\r');
sec=0;
while [ "$A" != "1" ]; do
echo "waiting emulator boot for "$sec" seconds";
sleep 10;
sec=$((sec + 10));
A=$(adb shell getprop sys.boot_completed | tr -d '\r');
done

echo "Emulator is ready"

0 comments on commit 9f8f97d

Please sign in to comment.