Created
November 4, 2018 18:00
-
-
Save davidtcdeveloper/70d9eecad64e6617e6c8024b05ca8b12 to your computer and use it in GitHub Desktop.
Creates an image for building Android Apps. Also enables instrumented tests ant emulator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Dockerfile for Android app build. Can be used for native Android builds. | |
| # | |
| # Before building, you need to replace the values of variables | |
| # ANDROID_SDK_LICENSE and ANDROID_SDK_PREVIEW_LICENSE (lines 70 and 71). | |
| # Replace these values with contents of files android-sdk-license | |
| # and android-sdk-preview-license that can be found at ANDROID_SDK/licenses. | |
| # The line breakes are mandatory, use \n to add them. | |
| FROM ubuntu:18.04 | |
| # Never ask for confirmations | |
| ENV DEBIAN_FRONTEND noninteractive | |
| # Update apt-get | |
| RUN rm -rf /var/lib/apt/lists/* | |
| RUN apt-get update | |
| RUN apt-get dist-upgrade -y | |
| # Installing packages | |
| RUN apt-get install -y \ | |
| autoconf \ | |
| build-essential \ | |
| bzip2 \ | |
| curl \ | |
| gcc \ | |
| git \ | |
| groff \ | |
| lib32stdc++6 \ | |
| lib32z1 \ | |
| lib32ncurses5 \ | |
| m4 \ | |
| openssh-client \ | |
| pkg-config \ | |
| software-properties-common \ | |
| unzip \ | |
| wget \ | |
| zip \ | |
| qemu-kvm libvirt-bin \ | |
| ubuntu-vm-builder \ | |
| bridge-utils \ | |
| --no-install-recommends | |
| # Install Java | |
| RUN apt-add-repository ppa:openjdk-r/ppa | |
| RUN apt-get update | |
| RUN apt-get -y install openjdk-8-jdk | |
| # Export JAVA_HOME variable | |
| ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ | |
| # Clean Up Apt-get | |
| RUN rm -rf /var/lib/apt/lists/* | |
| RUN apt-get clean | |
| # Install Android SDK | |
| RUN wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip | |
| RUN unzip sdk-tools-linux-4333796 | |
| RUN mkdir android-sdk-linux | |
| RUN mv tools android-sdk-linux/tools | |
| RUN rm sdk-tools-linux-4333796.zip | |
| ENV ANDROID_COMPONENTS platform-tools,android-28,build-tools-28.0.1,build-tools-28.0.0 | |
| # Environment variables | |
| ENV ANDROID_HOME /android-sdk-linux | |
| ENV ANDROID_SDK_HOME $ANDROID_HOME | |
| RUN echo "sdk.dir=$ANDROID_HOME" > local.properties | |
| # Accepts licences | |
| ENV ANDROID_SDK_LICENSE "YOUR LICENSE HERE" | |
| ENV ANDROID_SDK_PREVIEW_LICENSE "YOUR LICENSE HERE" | |
| RUN mkdir $ANDROID_SDK_HOME/licenses | |
| RUN printf $ANDROID_SDK_LICENSE > $ANDROID_SDK_HOME/licenses/android-sdk-license | |
| RUN printf $ANDROID_SDK_PREVIEW_LICENSE > $ANDROID_SDK_HOME/licenses/android-sdk-preview-license | |
| # Install Android tools | |
| RUN echo y | $ANDROID_SDK_HOME/tools/bin/sdkmanager "platform-tools" "platforms;android-28" "build-tools;28.0.3" "emulator" "system-images;android-28;default;x86" | |
| RUN echo no | $ANDROID_SDK_HOME/tools/bin/avdmanager create avd -n test -k "system-images;android-28;default;x86" | |
| # Cleaning | |
| RUN apt-get clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment