I'm trying to build an Alpine image containing the Android SDK - specifically, the platform-tools
package.
My Dockerfile does the following:
JAVA_HOME
(needed for Android).ANDROID_HOME
. Also sets PATH
so the sdkmanager
executable can be used.platform-tools
using sdkmanager
.platform-tools
to PATH
.platform-tools
contains an executable named adb
, but for some reason it cannot be seen. Running adb
returns:
bash: /android-sdk/platform-tools/adb: No such file or directory
Here is my Dockerfile:
FROM alpine:latest
# Install bash and java
RUN apk update
RUN apk add bash openjdk8
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
ENV PATH="$PATH:$JAVA_HOME/bin"
# Download Android SDK and set PATH
RUN mkdir /android-sdk
RUN wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip && unzip *.zip -d /android-sdk && rm *.zip
ENV ANDROID_HOME="/android-sdk"
ENV PATH="$PATH:$ANDROID_HOME/tools/bin"
# Install platform-tools
RUN yes | sdkmanager "platform-tools"
ENV PATH="$PATH:$ANDROID_HOME/platform-tools"
RUN adb version # throws error: adb not found
I've looked at this question but the problem should be fixed with platform-tools v24.0 and higher.
Alpine uses musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements.
adb
is compiled with glibc
, so it won't be able to run in Alpine, which usually results in the error: No such file or directory
.
You can verify that a file is compiled with glibc
by running file <path to file> | grep "interpreter /lib64/ld-linux-x86-64.so.2"
.