Skip to content

Instantly share code, notes, and snippets.

@vavrecan
Created January 29, 2026 00:45
Show Gist options
  • Select an option

  • Save vavrecan/c3c09222f1a08c453b97b7879a1bb27d to your computer and use it in GitHub Desktop.

Select an option

Save vavrecan/c3c09222f1a08c453b97b7879a1bb27d to your computer and use it in GitHub Desktop.
Build Android App
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# 1. Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential git cmake wget unzip openjdk-17-jdk \
python3 ninja-build pkg-config ca-certificates libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# 2. Setup Android SDK, NDK, and ANDROID CMAKE
ENV ANDROID_HOME=/opt/android-sdk
ENV ANDROID_NDK_VERSION=25.2.9519653
ENV PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools
RUN mkdir -p ${ANDROID_HOME}/cmdline-tools && \
wget -q https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -O /tmp/tools.zip && \
unzip /tmp/tools.zip -d ${ANDROID_HOME}/cmdline-tools && \
mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest && \
rm /tmp/tools.zip
# Added "cmake;3.22.1" here - this is what the script was screaming for
RUN yes | sdkmanager --licenses && \
sdkmanager "ndk;${ANDROID_NDK_VERSION}" "cmake;3.22.1" "platform-tools" "platforms;android-34" "build-tools;34.0.0"
ENV ANDROID_NDK_HOME=${ANDROID_HOME}/ndk/${ANDROID_NDK_VERSION}
# 3. Clone FreeRDP with submodules
WORKDIR /build
RUN git clone --depth 1 https://github.com/FreeRDP/FreeRDP.git . && \
git submodule update --init --recursive
# 4. Build Native ARM64 Libraries
# The script checks for $ANDROID_HOME/cmake. Sdkmanager installs it to $ANDROID_HOME/cmake/3.22.1.
# We might need to help the script find it.
RUN cd scripts && \
bash android-build-freerdp.sh \
--ndk $ANDROID_NDK_HOME \
--sdk $ANDROID_HOME \
--arch arm64-v8a
WORKDIR /build/client/Android/Studio
RUN chmod +x gradlew && \
# Create a real (but dummy) keystore file
keytool -genkey -v -keystore /build/release.keystore -alias dummyalias -keyalg RSA -keysize 2048 -validity 10000 \
-storepass password -keypass password -dname "CN=Android, OU=Dev, O=FreeRDP, L=Unknown, S=Unknown, C=US" && \
# Force the versionCode and Name
sed -i 's/versionCode .*/versionCode 1/g' aFreeRDP/build.gradle && \
sed -i 's/versionName .*/versionName "1.0.0"/g' aFreeRDP/build.gradle && \
# Point gradle.properties to the EXACT location of the new file
echo "android.useAndroidX=true" > gradle.properties && \
echo "android.enableJetifier=true" >> gradle.properties && \
echo "RELEASE_STORE_FILE=/build/release.keystore" >> gradle.properties && \
echo "RELEASE_STORE_PASSWORD=password" >> gradle.properties && \
echo "RELEASE_KEY_ALIAS=dummyalias" >> gradle.properties && \
echo "RELEASE_KEY_PASSWORD=password" >> gradle.properties && \
# Run the build
./gradlew assembleRelease
# Stage 2: Export results
FROM scratch AS export
# Grab the signed release APK
COPY --from=builder /build/client/Android/Studio/aFreeRDP/build/outputs/apk/release/*.apk /freerdp-release.apk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment