Skip to content

Instantly share code, notes, and snippets.

@mugifly
Created August 18, 2016 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mugifly/504a985f9f70cd9f797cc1621e82de01 to your computer and use it in GitHub Desktop.
Save mugifly/504a985f9f70cd9f797cc1621e82de01 to your computer and use it in GitHub Desktop.
Dockerfile for Build and CI of Android Projects - Included: fb-adb command, disabling system animation
FROM java:8
MAINTAINER Masanori Ohgita
# NOTE: This Dockerfile was forked from following projects.
# https://github.com/denlabo/dockerfile-android-project - Modified by Ohgita on denLabo LLC
# https://github.com/gfx/docker-android-project - Authored by FUJI Goro (MIT License)
ENV DEBIAN_FRONTEND noninteractive
# Install dependencies
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -yq libc6:i386 libstdc++6:i386 zlib1g:i386 libncurses5:i386 \
build-essential g++ unzip vim-common libssl-dev python-openssl --no-install-recommends && \
apt-get clean
# Download and untar Android SDK
ENV ANDROID_SDK_URL http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
RUN curl -L "${ANDROID_SDK_URL}" | tar --no-same-owner -xz -C /usr/local
ENV ANDROID_HOME /usr/local/android-sdk-linux
ENV ANDROID_SDK /usr/local/android-sdk-linux
ENV PATH ${ANDROID_HOME}/tools:$ANDROID_HOME/platform-tools:$PATH
# Download and untar Android NDK -- This may take a few minutes
ENV ANDROID_NDK_URL http://dl.google.com/android/ndk/android-ndk-r9b-linux-x86.tar.bz2
RUN curl -L "${ANDROID_NDK_URL}" | tar --no-same-owner -jx -C /usr/local
ENV ANDROID_NDK /usr/local/android-ndk-r9b
# Install fb-adb command
ENV FB_ADB_URL https://github.com/facebook/fb-adb/releases/download/1.4.4/fb-adb-1.4.4.tar.gz
RUN curl -L "${FB_ADB_URL}" | tar --no-same-owner -xz -C /usr/local
RUN cd /usr/local/fb-adb-1.4.4/ && mkdir build && cd build/ && ../configure && make && \
cp ./fb-adb /usr/local/bin/ && chmod u+x /usr/local/bin/fb-adb && rm -rf /usr/local/fb-adb-1.4.4/
# Install Android SDK components
# We can find package name on the command: android list sdk --extended --all
ARG ANDROID_COMPONENTS="platform-tools,build-tools-23.0.2,android-23,android-14,sys-img-armeabi-v7a-android-14"
ARG GOOGLE_COMPONENTS="extra-android-m2repository,extra-google-m2repository,extra-google-google_play_services"
RUN echo y | android update sdk --no-ui --all --filter "${ANDROID_COMPONENTS}" ; \
echo y | android update sdk --no-ui --all --filter "${GOOGLE_COMPONENTS}"
# Create the Android emulator
RUN echo n | android create avd -n test_android_14 -f -t android-14 && \
mksdcard -l e 128M sdcard.img
# Disable the animation settings on the android emulator
# See https://gist.github.com/mugifly/71fe92b769412ef2739a14d28c37043f
RUN emulator -avd test_android_14 -no-audio -no-boot-anim -no-window -sdcard sdcard.img -force-32bit & \
fb-adb wait-for-device && \
export DEVICE_DB_PATH="/data/data/com.android.providers.settings/databases/settings.db" && \
fb-adb shell "ls ${DEVICE_DB_PATH}" >/dev/null 2>&1 || \
while [ $? -ne 0 ]; do sleep 5; echo -n "."; fb-adb shell "ls ${DEVICE_DB_PATH}" >/dev/null 2>&1; done && \
fb-adb shell "echo \"update system set value=0.0 where name='window_animation_scale';\" | sqlite3 ${DEVICE_DB_PATH}" && \
fb-adb shell "echo \"update system set value=0.0 where name='transition_animation_scale';\" | sqlite3 ${DEVICE_DB_PATH}" && \
sleep 5 && fb-adb emu kill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment