Skip to content

[TrimmableTypeMap] Bump WorkManager test's AndroidX to post-KMP-split versions#12002

Merged
jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/workmanager-bump-androidx
Jul 7, 2026
Merged

[TrimmableTypeMap] Bump WorkManager test's AndroidX to post-KMP-split versions#12002
jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/workmanager-bump-androidx

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

BuildTest.WorkManager fails on the trimmable/NativeAOT path with:

ilc: error: Failed to load type 'AndroidX.Collection.SimpleArrayMap' from assembly 'Xamarin.AndroidX.Collection'

Root cause

The test 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. Both were built before the androidx.collection Kotlin-Multiplatform split: the types (SimpleArrayMap, ArrayMap, …) later moved out of Xamarin.AndroidX.Collection into Xamarin.AndroidX.Collection.Jvm, and the old facade Xamarin.AndroidX.Collection.dll was emptied (0 types, 0 type-forwards) without a [TypeForwardedTo] being added.

So those older assemblies carry a dangling TypeRef [Xamarin.AndroidX.Collection]AndroidX.Collection.SimpleArrayMap that now points at an empty assembly.

  • MonoVM / CoreCLR (JIT) never notice: type references resolve lazily, only when a type is actually used, and this path is never exercised (real usages reach SimpleArrayMap through the correct .Jvm reference from newer assemblies).
  • NativeAOT / ILC does whole-program compilation and resolves the reference eagerly while building vtables for constructed types, so it trips over the dangling reference and fails the build.

Fix

Reference a current Xamarin.Google.Android.Material (1.10.0.2, already KnownPackages.XamarinGoogleAndroidMaterial). It references Xamarin.AndroidX.Collection.Jvm and depends on Xamarin.AndroidX.Fragment 1.6.2.1, so both stale Forms-transitive packages resolve to post-split versions and the dangling reference disappears.

This is a test-only change (no product change) — the underlying binding-packaging issue (missing type-forward on the emptied Xamarin.AndroidX.Collection facade) lives in the AndroidX bindings, not this repo.

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>
Copilot AI review requested due to automatic review settings July 7, 2026 09:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a test-only NativeAOT/trimmable build break in BuildTest.WorkManager caused by older Xamarin.Forms transitive AndroidX packages that reference types moved during the AndroidX.Collection KMP split.

Changes:

  • Add an explicit reference to KnownPackages.XamarinGoogleAndroidMaterial in the WorkManager test to force resolution to post-split AndroidX packages (including Xamarin.AndroidX.Collection.Jvm).
  • Document the rationale in the test to explain why the explicit package reference is needed for NativeAOT/ILC.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs Adds an explicit Material package reference (and explanation) to avoid NativeAOT failing on dangling AndroidX.Collection type refs in the WorkManager test.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

@jonathanpeppers jonathanpeppers enabled auto-merge (squash) July 7, 2026 13:10
@simonrozsival simonrozsival changed the title [Tests] Bump WorkManager test's AndroidX to post-KMP-split versions [TrimmableTypeMap] Bump WorkManager test's AndroidX to post-KMP-split versions Jul 7, 2026
@simonrozsival simonrozsival added copilot `copilot-cli` or other AIs were used to author this trimmable-type-map labels Jul 7, 2026
@jonathanpeppers jonathanpeppers merged commit 86b6b3a into main Jul 7, 2026
43 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/simonrozsival/workmanager-bump-androidx branch July 7, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot `copilot-cli` or other AIs were used to author this trimmable-type-map

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants