Skip to content

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

Merged
jonathanpeppers merged 6 commits intomainfrom
dev/simonrozsival/fix-gradle-test-agp-version
Apr 2, 2026
Merged

[Tests] Bump default AGP to 9.1.0 for compileSdk 36 compatibility#11043
jonathanpeppers merged 6 commits intomainfrom
dev/simonrozsival/fix-gradle-test-agp-version

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

@simonrozsival simonrozsival commented Mar 30, 2026

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 XABuildConfig.AndroidDefaultTargetDotnetApiLevel (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.

simonrozsival and others added 5 commits March 31, 2026 11:11
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 jonathanpeppers merged commit fccdfda into main Apr 2, 2026
6 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/simonrozsival/fix-gradle-test-agp-version branch April 2, 2026 16:31
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

3 participants