[Tests] Bump default AGP to 9.1.0 for compileSdk 36 compatibility#11043
[Tests] Bump default AGP to 9.1.0 for compileSdk 36 compatibility#11043simonrozsival wants to merge 2 commits intomainfrom
Conversation
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>
There was a problem hiding this comment.
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
AndroidGradleProjectfrom 8.5.0 to 9.1.0 and set a default Gradle wrapper version (9.1.0). - Extend
AndroidGradleProject.CreateDefault(versioned overload) with an optionalcompileSdkparameter. - Adjust
BindLibraryWithMultipleGradleVersionstest data to usecompileSdk = 34for 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. |
There was a problem hiding this comment.
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).
| /// 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. |
| /// Creates a default Gradle project with specified AGP and Gradle versions. | ||
| /// </summary> |
There was a problem hiding this comment.
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.
| /// 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> |
| IsApplication = isApplication, | ||
| CompileSdk = compileSdk ?? XABuildConfig.AndroidDefaultTargetDotnetApiLevel.Major, | ||
| }, |
There was a problem hiding this comment.
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).
Fixes CS0103: 'XABuildConfig' does not exist in the current context. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
AgpVersionwas hardcoded to8.5.0inAndroidGradleProject.cs, whileCompileSdkis dynamically derived fromAndroidLatestStableApiLevel(now 36). AGP 8.5.0 only supports up to compileSdk 34, causing a Gradle configuration-cache serialization crash inMergeJavaResourceTaskfor tests likeBuildMultipleModules(MonoVM).See the AGP compatibility table for details.
Changes
AndroidGradleProject.cs: Bump defaultAgpVersionfrom"8.5.0"→"9.1.0"and set defaultGradleVersionto"9.1.0"AndroidGradleProject.cs: Add optionalcompileSdkparameter toCreateDefaultoverloadAndroidGradleProjectTests.cs: FixBindLibraryWithMultipleGradleVersions— the AGP 8.5.0 test case now usescompileSdk = 34(within its supported range), while the AGP 9.0.0 case uses the current defaultCustomer Impact
None — these changes are test-infrastructure only (
Xamarin.ProjectToolsnamespace). Real customer projects specify their own AGP version in theirbuild.gradle.kts.Fixes #11042