From 762a4e2d0966e53ebe836ba0e161dfe181bc8ce8 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Tue, 7 Jul 2026 11:45:47 +0200 Subject: [PATCH] [Tests] Bump WorkManager test's AndroidX to post-KMP-split versions BuildTest.WorkManager uses XamarinFormsAndroidApplicationProject, whose Xamarin.Forms 5.0.0.2622 transitively pulls Xamarin.AndroidX.Fragment 1.5.5 and Xamarin.Google.Android.Material 1.4.0.2. Those were built before the androidx.collection Kotlin-Multiplatform split and carry dangling type references to AndroidX.Collection.SimpleArrayMap in the now type-less Xamarin.AndroidX.Collection facade (the type moved to Xamarin.AndroidX.Collection.Jvm without a type-forward being added). MonoVM/CoreCLR never notice (type references resolve lazily and this path is never exercised), but NativeAOT/ILC resolves the reference eagerly while building vtables for constructed types and fails with "Failed to load type 'AndroidX.Collection.SimpleArrayMap'". Reference a current Xamarin.Google.Android.Material (1.10.0.2), which references Xamarin.AndroidX.Collection.Jvm and depends on Xamarin.AndroidX.Fragment 1.6.2.1, so both stale transitive packages resolve to post-split versions. Fixes BuildTest.WorkManager on the trimmable/NativeAOT path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Tests/Xamarin.Android.Build.Tests/BuildTest.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index 2d449e73fc1..fabd888d41e 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -1376,6 +1376,13 @@ public MyWorker (Context c, WorkerParameters p) : base (c, p) { } }); proj.PackageReferences.Add (KnownPackages.AndroidXWorkRuntime); proj.PackageReferences.Add (KnownPackages.AndroidXLifecycleLiveData); + // Xamarin.Forms 5.0.0.2622 transitively pulls old Xamarin.AndroidX.Fragment (1.5.5) and + // Xamarin.Google.Android.Material (1.4.0.2) that were compiled before the AndroidX.Collection + // KMP split and carry dangling type references to AndroidX.Collection.SimpleArrayMap in the now + // type-less Xamarin.AndroidX.Collection facade. NativeAOT/ILC resolves those references eagerly + // while building vtables and fails to load the type. Reference a current Material (which depends + // on Fragment 1.6.2.1) so both resolve to Xamarin.AndroidX.Collection.Jvm. + proj.PackageReferences.Add (KnownPackages.XamarinGoogleAndroidMaterial); using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); }