Skip to content

[Tests] Bump default AGP to 9.1.0 for compileSdk 36 compatibility#11043

Open
simonrozsival wants to merge 1 commit intomainfrom
dev/simonrozsival/fix-gradle-test-agp-version
Open

[Tests] Bump default AGP to 9.1.0 for compileSdk 36 compatibility#11043
simonrozsival wants to merge 1 commit intomainfrom
dev/simonrozsival/fix-gradle-test-agp-version

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

Summary

Bumps the default Android Gradle Plugin (AGP) version in the test infrastructure from 8.5.0 to 9.1.0 to fix Gradle test failures caused by an AGP/compileSdk version mismatch.

Problem

The default AgpVersion was hardcoded to 8.5.0 in AndroidGradleProject.cs, while CompileSdk is dynamically derived from AndroidLatestStableApiLevel (now 36). AGP 8.5.0 only supports up to compileSdk 34, causing a Gradle configuration-cache serialization crash in MergeJavaResourceTask for tests like BuildMultipleModules(MonoVM).

See the AGP compatibility table for details.

Changes

  • AndroidGradleProject.cs: Bump default AgpVersion from "8.5.0""9.1.0" and set default GradleVersion to "9.1.0"
  • AndroidGradleProject.cs: Add optional compileSdk parameter to CreateDefault overload
  • AndroidGradleProjectTests.cs: Fix BindLibraryWithMultipleGradleVersions — the AGP 8.5.0 test case now uses compileSdk = 34 (within its supported range), while the AGP 9.0.0 case uses the current default

Customer Impact

None — these changes are test-infrastructure only (Xamarin.ProjectTools namespace). Real customer projects specify their own AGP version in their build.gradle.kts.

Fixes #11042

The default AgpVersion in the test infrastructure was hardcoded to 8.5.0,
which only supports up to compileSdk 34. Since AndroidLatestStableApiLevel
moved to 36, the Gradle tests fail with a configuration-cache serialization
error in MergeJavaResourceTask.

Changes:
- Bump default AgpVersion from 8.5.0 to 9.1.0
- Set default GradleVersion to 9.1.0 (required by AGP 9.x)
- Add compileSdk parameter to CreateDefault overload
- Fix BindLibraryWithMultipleGradleVersions to use compileSdk=34 for AGP 8.5.0

Fixes #11042

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 30, 2026 11:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Gradle test infrastructure defaults to use newer Android Gradle Plugin (AGP) and Gradle versions, addressing test failures when compileSdk is at/near the current stable API level.

Changes:

  • Bump default AGP version in AndroidGradleProject from 8.5.0 to 9.1.0 and set a default Gradle wrapper version (9.1.0).
  • Extend AndroidGradleProject.CreateDefault (versioned overload) with an optional compileSdk parameter.
  • Adjust BindLibraryWithMultipleGradleVersions test data to use compileSdk = 34 for AGP 8.5.0, and current default for newer AGP.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidGradleProject.cs Updates default AGP/Gradle versions and adds compileSdk override support when creating default Gradle projects.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidGradleProjectTests.cs Updates parameterized test data and signature to include compileSdk for version-compat test coverage.


/// <summary>
/// Gradle wrapper version to use (e.g., "8.12", "9.0").
/// If null or empty, the Gradle wrapper version generated by gradle init is used.
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The XML doc for GradleVersion says the wrapper version is used “if null or empty”, but the property is now initialized to "9.1.0" by default. Consider updating this comment to reflect the new default behavior (i.e., wrapper version will be overridden unless callers explicitly set it to null/empty).

Suggested change
/// If null or empty, the Gradle wrapper version generated by gradle init is used.
/// Defaults to "9.1.0". If set to null or empty, the Gradle wrapper version generated by gradle init is used.

Copilot uses AI. Check for mistakes.
Comment on lines 77 to 78
/// Creates a default Gradle project with specified AGP and Gradle versions.
/// </summary>
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

CreateDefault’s summary mentions only AGP/Gradle versions, but the method now also takes an optional compileSdk parameter. Please update the XML docs to mention what compileSdk controls and what default is used when it’s omitted.

Suggested change
/// Creates a default Gradle project with specified AGP and Gradle versions.
/// </summary>
/// Creates a default Gradle project with specified AGP, Gradle, and compileSdk versions.
/// When <paramref name="compileSdk" /> is <c>null</c>, the default value
/// <see cref="XABuildConfig.AndroidDefaultTargetDotnetApiLevel.Major" /> is used.
/// </summary>
/// <param name="compileSdk">
/// The Android compileSdk level to use for the created module. If omitted or <c>null</c>,
/// the project will use <see cref="XABuildConfig.AndroidDefaultTargetDotnetApiLevel.Major" />.
/// </param>

Copilot uses AI. Check for mistakes.
Comment on lines 86 to 88
IsApplication = isApplication,
CompileSdk = compileSdk ?? XABuildConfig.AndroidDefaultTargetDotnetApiLevel.Major,
},
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

PR description states the default compileSdk is derived from AndroidLatestStableApiLevel, but here the default/fallback is XABuildConfig.AndroidDefaultTargetDotnetApiLevel.Major. Please align the PR description with the implementation (or switch to AndroidLatestStableApiLevel if that’s the intended source).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tests] Gradle tests fail with AGP 8.5.0 and compileSdk 36 — configuration-cache serialization error

2 participants