Skip to content

Instantly share code, notes, and snippets.

@stefanJi
Created November 4, 2020 11:10
Show Gist options
  • Save stefanJi/0b2d27510ece621ebc473d8f75037efd to your computer and use it in GitHub Desktop.
Save stefanJi/0b2d27510ece621ebc473d8f75037efd to your computer and use it in GitHub Desktop.
Docker 配置 Android SDK 环境, 也适应与 Linux 环境下
FROM ubuntu:20.04
ENV ANDROID_COMPILE_SDK=30
ENV ANDROID_BUILD_TOOLS=30.0.1
ENV ANDROID_NDK_VERSION=21.0.6113669
ARG ANDROID_SDK_VERSION=6609375
ENV ANDROID_SDK_ROOT /opt/android-sdk
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-get clean
RUN apt-get update
RUN apt-get install -y --no-install-recommends wget unzip openjdk-8-jdk libncurses5
ENV PATH ${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin:${ANDROID_SDK_ROOT}/platform-tools
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && \
unzip *tools*linux*.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
rm *tools*linux*.zip
RUN echo y | sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
RUN echo y | sdkmanager "platform-tools" >/dev/null
RUN echo y | sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
RUN echo y | sdkmanager "ndk;${ANDROID_NDK_VERSION}" >/dev/null
RUN yes | sdkmanager --licenses
RUN printenv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment