Skip to content

[Tests] Retry flaky InstallAndroidDependenciesTest download#11974

Open
simonrozsival wants to merge 1 commit into
dotnet:mainfrom
simonrozsival:dev/simonrozsival/retry-install-android-dependencies
Open

[Tests] Retry flaky InstallAndroidDependenciesTest download#11974
simonrozsival wants to merge 1 commit into
dotnet:mainfrom
simonrozsival:dev/simonrozsival/retry-install-android-dependencies

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Description

InstallAndroidDependenciesTest exercises the InstallAndroidDependencies target, which downloads the Android SDK and JDK over the network. Because there is no caching (the test wipes and recreates the SDK/JDK directories on every run), these downloads fail intermittently in CI — causing the ("GoogleV2", CoreCLR) and ("Xamarin", CoreCLR) cases to fail randomly across unrelated PRs.

Typical failure (a short 2–4s FailedBuildException, with the real error hidden in the per-test install-deps.log artifact):

Failed InstallAndroidDependenciesTest("GoogleV2",CoreCLR) [4 s]
  Xamarin.ProjectTools.FailedBuildException : Build failure: UnnamedProject.csproj

Change

Retry the InstallAndroidDependencies build up to 3 times:

  • Wait 10 seconds between attempts.
  • Start from a clean SDK/JDK directory on each attempt, so a partial/corrupt download from a failed attempt cannot poison the next one.
  • Only fail after all 3 attempts are exhausted, logging each failed attempt for triage.

Notes

This is a mitigation for the CI flakiness, not a confirmed root-cause fix — the underlying network failure still needs to be characterized from install-deps.log. The tracking issue is intentionally left open for that investigation.

Mitigates #11973

InstallAndroidDependenciesTest exercises the InstallAndroidDependencies
target, which downloads the Android SDK and JDK over the network. These
downloads fail intermittently in CI, causing the ("GoogleV2", CoreCLR)
and ("Xamarin", CoreCLR) cases to fail randomly across unrelated PRs.

Retry the install build up to 3 times, waiting 10 seconds between
attempts and starting from a clean SDK/JDK directory each time so a
partial download does not affect the next attempt.

Mitigates dotnet#11973
Copilot AI review requested due to automatic review settings July 3, 2026 21:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Mitigates CI flakiness in InstallAndroidDependenciesTest by adding retry logic around the network-dependent InstallAndroidDependencies build target (SDK/JDK downloads), reducing random failures in unrelated PRs.

Changes:

  • Add up-to-3 retry loop for InstallAndroidDependencies with a 10s backoff between attempts.
  • Recreate the SDK/JDK directories on each attempt to avoid partial/corrupt downloads affecting subsequent retries.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidDependenciesTests.cs Adds retry/backoff + per-attempt cleanup to reduce network-related test flakiness in CI.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines +69 to +91
// InstallAndroidDependencies downloads the Android SDK and JDK over the network, which
// can fail intermittently in CI. Retry a few times before giving up, starting from a
// clean SDK/JDK directory each attempt so a partial download does not affect the next.
// See https://github.com/dotnet/android/issues/11973
const int maxInstallAttempts = 3;
bool installSucceeded = false;
for (int attempt = 1; attempt <= maxInstallAttempts; attempt++) {
foreach (var path in new [] { sdkPath, jdkPath }) {
if (Directory.Exists (path))
Directory.Delete (path, recursive: true);
Directory.CreateDirectory (path);
}

if (b.Build (proj, parameters: buildArgs.ToArray ())) {
installSucceeded = true;
break;
}

TestContext.WriteLine ($"InstallAndroidDependencies attempt {attempt} of {maxInstallAttempts} failed. Please check the task output in 'install-deps.log'.");
if (attempt < maxInstallAttempts)
Thread.Sleep (TimeSpan.FromSeconds (10));
}
Assert.IsTrue (installSucceeded, $"InstallAndroidDependencies should have succeeded within {maxInstallAttempts} attempts.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants