[Tests] Bump default AGP to 9.1.0 for compileSdk 36 compatibility#11043
Merged
jonathanpeppers merged 6 commits intomainfrom Apr 2, 2026
Merged
[Tests] Bump default AGP to 9.1.0 for compileSdk 36 compatibility#11043jonathanpeppers merged 6 commits intomainfrom
jonathanpeppers merged 6 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>
Contributor
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. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidGradleProject.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidGradleProject.cs
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidGradleProject.cs
Show resolved
Hide resolved
Fixes CS0103: 'XABuildConfig' does not exist in the current context. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AGP 9.1.0 requires Gradle >= 9.3.1, not 9.1.0. The previous default caused all Gradle-based tests to fail with: 'Minimum supported Gradle version is 9.3.1. Current version is 9.1.0.' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AGP 9.1.0 with compileSdk 36 enforces the Android 12 requirement that activities with intent filters must explicitly declare android:exported. The SetupDefaultApp() manifest template was missing this attribute, causing BuildApp and BuildMultipleModules tests to fail with: android:exported needs to be explicitly specified for element <activity#com.example.TestModule.TestActivity> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jonathanpeppers
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fromXABuildConfig.AndroidDefaultTargetDotnetApiLevel(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