From 832188d5c7379bfee35c306119c132d0c47c5a40 Mon Sep 17 00:00:00 2001 From: Jason Ernst Date: Thu, 27 Aug 2026 06:49:01 -0700 Subject: [PATCH] fix: retry sdkmanager install on transient download failures sdkmanager has no download retry. A truncated download from dl.google.com (seen in the PR #80 JDK 17 build as "An error occurred while preparing SDK package CMake 3.22.1: Archive is not a ZIP archive") fails the whole image build even though the Dockerfile is fine. sdkmanager is idempotent, so wrap the install in an until-loop that retries up to 3 times, clearing the SDK's .temp download dir between attempts so a corrupt partial archive is not reused. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_012jviQGmp5ey58RmYqoPssC --- Dockerfile | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index da406ce..77bff78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,12 +50,24 @@ RUN ${ANDROID_ROOT}/sdk/cmdline-tools/latest/bin/sdkmanager --licenses >/dev/nul # build-tools and NDK are backward compatible, and you only need the platform # matching your project's compileSdk. Projects needing older platforms can install # them at build time via sdkmanager. -RUN echo "y" | ${ANDROID_ROOT}/sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_ROOT/sdk/ \ - "platform-tools" \ - "platforms;android-${COMPILE_SDK}" \ - "build-tools;${BUILD_TOOLS}" \ - "ndk;${NDK_VERSION}" \ - "cmake;3.22.1" +# +# sdkmanager has no download retry: a truncated download from dl.google.com +# surfaces as "Archive is not a ZIP archive" and fails the whole build. It is +# idempotent (already-installed packages are skipped), so retry the whole +# command a few times, clearing its download scratch dir between attempts. +RUN attempt=1; \ + until echo "y" | ${ANDROID_ROOT}/sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_ROOT/sdk/ \ + "platform-tools" \ + "platforms;android-${COMPILE_SDK}" \ + "build-tools;${BUILD_TOOLS}" \ + "ndk;${NDK_VERSION}" \ + "cmake;3.22.1"; do \ + if [ "$attempt" -ge 3 ]; then echo "sdkmanager failed after $attempt attempts" >&2; exit 1; fi; \ + echo "sdkmanager attempt $attempt failed, retrying in 15s..." >&2; \ + rm -rf ${ANDROID_ROOT}/sdk/.temp; \ + attempt=$((attempt + 1)); \ + sleep 15; \ + done WORKDIR /actions-runner ENV PATH="${PATH}:/usr/local/lib/android/sdk/platform-tools/"