-
Notifications
You must be signed in to change notification settings - Fork 566
Description
Summary
The BuildMultipleModules(MonoVM) test in AndroidGradleProjectTests.cs fails with a Gradle configuration-cache serialization error. The root cause is a version mismatch between the hardcoded default AGP version (8.5.0) and the dynamically derived compileSdk (36).
Failing Build
- Internal CI build: https://devdiv.visualstudio.com/0bdbc590-a062-4c3f-b0f6-9383f67865ee/_build/results?buildId=13686026
- Failed job: macOS > Tests > MSBuild 4
- Failed test:
BuildMultipleModules(MonoVM)inAndroidGradleProjectTests.cs
Root Cause
The test infrastructure has two values that have drifted apart:
AgpVersion— hardcoded default of"8.5.0"inAndroidGradleProject.cs:19CompileSdk— dynamically derived fromAndroidLatestStableApiLevel(currently 36) inAndroidGradleModule.cs:18
AGP 8.5.0 was only tested up to compileSdk 34. When used with compileSdk 36 and Gradle configuration-cache enabled, AGP hits a serialization bug.
Build Log Errors
AGP warning:
WARNING: We recommend using a newer Android Gradle plugin to use compileSdk = 36
This Android Gradle plugin (8.5.0) was tested up to compileSdk = 34.
Configuration-cache crash:
FAILURE: Build failed with an exception.
Configuration cache state could not be cached: field `elements` of
`org.gradle.internal.serialize.codecs.core.ResolutionBackedFileCollectionSpec`
bean found in field `__externalLibJavaRes__` of task
`:TestAppModule:mergeDebugJavaResource` of type
`com.android.build.gradle.internal.tasks.MergeJavaResourceTask`:
error writing value of type 'java.util.ArrayList'
MSBuild error:
error MSB6006: "gradlew" exited with code 1.
References
- AGP / compileSdk compatibility table — the link AGP itself prints in the warning
- About Android Gradle Plugin releases — AGP version requirements
- AGP 9.0.0 release notes — first version with compileSdk 36 support
Proposed Fix
Bump the default AgpVersion (and corresponding Gradle version) to a version that supports the current compileSdk. The existing BindLibraryWithMultipleGradleVersions test already uses AGP 9.0.0 + Gradle 9.1.0 as a test case, so bumping the defaults to match would be the simplest fix:
// AndroidGradleProject.cs
public string AgpVersion { get; set; } = "9.0.0";Alternatively, the default could be made dynamic based on CompileSdk, using AGP 8.5.0 for compileSdk ≤ 34 and AGP 9.0.0+ for compileSdk ≥ 35.
Notes
- This is not specific to any PR — it affects any branch targeting
mainsinceAndroidLatestStableApiLevelmoved to 36. - All public CI (Linux, macOS, Windows builds on
dnceng-public) passes fine — this only affects the internalXamarin.Android-PRpipeline which runs the MSBuild integration tests.