FROM gradle:8.14-jdk8-jammy
# Android SDK installation and environment
ENV ANDROID_SDK_ROOT=/opt/android-sdk
ENV ANDROID_HOME=$ANDROID_SDK_ROOT
ENV PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/platform-tools
# Install required system tools
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl unzip zip ca-certificates git \
&& rm -rf /var/lib/apt/lists/*
# Install Android Command-line Tools and SDK platforms/tools
RUN mkdir -p "$ANDROID_SDK_ROOT" \
&& mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools" \
&& curl -o /tmp/commandlinetools-linux.zip -L https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip \
&& unzip -q /tmp/commandlinetools-linux.zip -d "$ANDROID_SDK_ROOT/cmdline-tools" \
&& mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest" \
&& yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --licenses \
&& "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" "platforms;android-30" "build-tools;30.0.3" "platform-tools" \
&& rm -f /tmp/commandlinetools-linux.zip
# Environment for Java 8
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
# Workspace setup
WORKDIR /workspace
# Copy source
COPY . /workspace
# Ensure gradlew is executable
RUN chmod +x ./gradlew
# Provide local.properties pointing to the Android SDK (required by Gradle Android plugin)
RUN bash -lc "echo sdk.dir=$ANDROID_SDK_ROOT > local.properties"
# Build the project from source (skip tests for speed in CI)
RUN ./gradlew clean assemble -x test
# Show build outputs (if any)
RUN ls -la app/build/outputs/apk || true
# Keep container alive after build to allow inspection if needed
CMD ["bash", "-lc", "echo Build complete. APKs (if any) are under app/build/outputs/apk; tail -f /dev/null"]
# Ignore common VCS and IDE folders .git .gitignore node_modules build .gradle out *.iml .gradle/* .idea .local .DS_Store # Android Studio files .local.properties .settings
- VerifyBuild status: build_failed - Root cause - java.lang.UnsupportedClassVersionError: com/android/prefs/AndroidLocationsProvider has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 - The Android command-line tools require Java 11+ (55.0), but the base image uses Java 8 (52.0). Dockerfile uses gradle:8.14-jdk8-jammy. - Exit code: 1 - Failing step - Step [3/9] RUN mkdir -p "/opt/android-sdk" && mkdir -p "/opt/android-sdk/cmdline-tools" && curl -o /tmp/commandlinetools-linux.zip -L https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip && unzip -q /tmp/commandlinetools-linux.zip -d "/opt/android-sdk/cmdline-tools" && mv "/opt/android-sdk/cmdline-tools/cmdline-tools" "/opt/android-sdk/cmdline-tools/latest" && yes | "/opt/android-sdk/cmdline-tools/latest/bin/sdkmanager" --licenses && "/opt/android-sdk/cmdline-tools/latest/bin/sdkmanager" "platforms;android-30" "build-tools;30.0.3" "platform-tools" && rm -f /tmp/commandlinetools-linux.zip - Missing packages/files - Note: apt-utils is not installed (debconf: delaying package configuration, since apt-utils is not installed) - No explicit missing file reported; failure is due to Java version mismatch during sdkmanager execution - Additional context / versions - Class file version mismatch: 55.0 (required) vs 52.0 (supported by Java 8) - Java environment: JDK 8 in gradle:8.14-jdk8-jammy - Command-line tools ZIP: commandlinetools-linux-9477386_latest.zip - sdkmanager targets: platforms;android-30, build-tools;30.0.3, platform-tools - Note: Build also mentions that the Dockerfile builds an Android APK and that smoke test only verifies APK packaging via aapt, not running on device.
Image gradle:8.*-jdk11 NOT found on Docker Hub.
Image gradle:8.1-jdk11-jammy exists on Docker Hub.
Image gradle:8.14-jdk8-jammy exists on Docker Hub.
Image gradle:8.14-jdk11-jammy exists on Docker Hub.
FROM gradle:8.14-jdk11-jammy
# Android SDK installation and environment
ENV ANDROID_SDK_ROOT=/opt/android-sdk
ENV ANDROID_HOME=$ANDROID_SDK_ROOT
ENV PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/platform-tools
# Install required system tools
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl unzip zip ca-certificates git \
&& rm -rf /var/lib/apt/lists/*
# Install Android Command-line Tools and SDK platforms/tools
RUN mkdir -p "$ANDROID_SDK_ROOT" \
&& mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools" \
&& curl -o /tmp/commandlinetools-linux.zip -L https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip \
&& unzip -q /tmp/commandlinetools-linux.zip -d "$ANDROID_SDK_ROOT/cmdline-tools" \
&& mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest" \
&& yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --licenses \
&& "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" "platforms;android-30" "build-tools;30.0.3" "platform-tools" \
&& rm -f /tmp/commandlinetools-linux.zip
# Environment for Java 11
ENV JAVA_HOME=/usr/local/openjdk-11
# Work directory
WORKDIR /workspace
# Copy source
COPY . /workspace
# Ensure gradlew is executable
RUN chmod +x ./gradlew
# Provide local.properties pointing to the Android SDK (required by Gradle Android plugin)
RUN bash -lc "echo sdk.dir=$ANDROID_SDK_ROOT > local.properties"
# Build the project from source (skip tests for speed in CI)
RUN ./gradlew clean assemble -x test
# Show build outputs (if any)
RUN ls -la app/build/outputs/apk || true
# Keep container alive after build to allow inspection if needed
CMD ["bash", "-lc", "echo Build complete. APKs (if any) are under app/build/outputs/apk; tail -f /dev/null"]
Summary (under 1500 chars):
- Exact error message and exit code
- Error: "ERROR: JAVA_HOME is set to an invalid directory: /usr/local/openjdk-11"
- Follow-up: "Please set the JAVA_HOME variable in your environment to match the location of your Java installation."
- Exit code: 1
- Failing command/step
- [8/9] RUN ./gradlew clean assemble -x test
- Missing packages or files mentioned
- No missing package/file is explicitly logged. The issue is that the JAVA_HOME path is invalid ("/usr/local/openjdk-11" not found).
- Version mismatch info
- Base image indicates Gradle 8.14 with JDK 11 (gradle:8.14-jdk11-jammy).
- The error shows JAVA_HOME points to /usr/local/openjdk-11, which is not a valid/installed location in the image, indicating a mismatch between the expected JDK location and the actual JAVA_HOME.