Skip to content

ci(android): pre-install NDK with retry to fix corrupt-zip flake#150

Merged
gmaclennan merged 1 commit into
mainfrom
ci/ndk-install-retry
Jun 23, 2026
Merged

ci(android): pre-install NDK with retry to fix corrupt-zip flake#150
gmaclennan merged 1 commit into
mainfrom
ci/ndk-install-retry

Conversation

@gmaclennan

Copy link
Copy Markdown
Member

Problem

The release merge queue (PR #149) failed on Instrumented Tests (30) — but no test actually ran. The job died in the Build test APKs step:

Warning: An error occurred while preparing SDK package NDK (Side by side) 27.1.12297006: Error on ZipFile unknown archive.
java.util.zip.ZipException: Archive is not a ZIP archive
"Install NDK (Side by side) 27.1.12297006 v.27.1.12297006" failed.
FAILURE: Build failed with an exception.

The same commit passed an earlier merge-queue run, confirming it's an infrastructure flake, not a code/test failure. We've hit this before.

Root cause

The instrumented-tests job removes all pre-installed NDKs (rm -rf $ANDROID_HOME/ndk) to save disk. Gradle then auto-downloads the required NDK (27.1.12297006, from React Native's libs.versions.toml via Expo's default) on-the-fly during the build — a single-shot sdkmanager download with no retry. When that fetch lands a corrupt zip, the whole job fails.

Fix

  • Pin the NDK version in an env var with a comment pointing at its source.
  • Cache the NDK keyed on its version — most runs skip the download entirely.
  • On a cache miss, install it up front with a 3-attempt retry that purges the partial download between tries.

Gradle then finds the NDK already present and never does the unguarded in-build download. Only the instrumented-tests job is affected; the JVM unit-tests job doesn't build native code.

Validated with actionlint (clean).

The instrumented-tests job removes all pre-installed NDKs, so Gradle
auto-downloaded the required NDK mid-build with no retry. That single-shot
sdkmanager download occasionally fetched a corrupt archive ("Error on
ZipFile unknown archive"), failing the build before any test ran and
blocking the release merge queue.

Cache the NDK keyed on its version and, on a cache miss, install it up
front with a 3-attempt retry that purges the partial download between
tries. Gradle then finds it already present and never does the unguarded
in-build download.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gmaclennan gmaclennan enabled auto-merge June 23, 2026 16:58
@github-actions github-actions Bot added the maintenance Refactor / test / chore / ci / build (changelog) label Jun 23, 2026
@gmaclennan gmaclennan added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit 8c01072 Jun 23, 2026
21 checks passed
@gmaclennan gmaclennan deleted the ci/ndk-install-retry branch June 23, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Refactor / test / chore / ci / build (changelog)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant