Created
June 18, 2023 10:47
-
-
Save tugceaktepe/8509b0f5d2556d5fc33be57586f0b60c to your computer and use it in GitHub Desktop.
Android SDK Setup in Docker image
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
FROM example-registry.company-domain.com/image/openjdk:11 | |
ENV ANDROID_COMPILE_SDK=33 | |
ENV ANDROID_BUILD_TOOLS=33.0.0 | |
ENV ANDROID_SDK_TOOLS=6514223 | |
ENV EMULATOR_VERSION=24 | |
SHELL ["/bin/bash", "-c"] | |
RUN apt-get --quiet update --yes | |
RUN apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 | |
# Setup path as android_home for moving/exporting the downloaded sdk into it | |
ENV ANDROID_HOME="$PWD/android-home" | |
ENV ANDROID_SDK_ROOT=$ANDROID_HOME | |
RUN echo "ANDROID_HOME: $ANDROID_HOME" | |
# Create a new directory at specified location | |
RUN install -d ${ANDROID_HOME} | |
# Here we are installing androidSDK tools from official source, | |
# (the key thing here is the url from where you are downloading these sdk tool for command line, so please do note this url pattern there and here as well) | |
# after that unzipping those tools and | |
# then running a series of SDK manager commands to install necessary android SDK packages that'll allow the app to build | |
RUN wget --output-document=${ANDROID_HOME}/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip | |
# move to the archive at ANDROID_HOME | |
RUN unzip -d $ANDROID_HOME/cmdline-tools ${ANDROID_HOME}/cmdline-tools.zip | |
ENV PATH=$PATH:$ANDROID_HOME/cmdline-tools/tools/bin/:$ANDROID_HOME/platform-tools:$ANDROID_SDK_ROOT/emulator | |
RUN pwd | |
RUN echo $PATH | |
# Nothing fancy here, just checking sdkManager version | |
RUN sdkmanager --version | |
# use yes to accept all licenses | |
RUN yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses || true | |
RUN sdkmanager --sdk_root=${ANDROID_HOME} "platforms;android-${ANDROID_COMPILE_SDK}" | |
RUN sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools" | |
RUN sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;${ANDROID_BUILD_TOOLS}" | |
RUN ls $ANDROID_HOME | |
RUN apt-get install hwinfo --yes | |
RUN hwinfo --short | |
RUN apt-get --quiet update --yes | |
RUN apt-get --quiet install --yes libx11-dev libpulse0 libgl1 libnss3 libxcomposite-dev libxcursor1 libasound2 | |
RUN wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator | |
RUN chmod +x android-wait-for-emulator | |
RUN sdkmanager --update > update.log | |
RUN sdkmanager "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};default;x86_64" > installEmulator.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment