Full Linking Support for Reflection-Based Libraries in Xamarin.Android Release Builds
0 reputation · 10 Jul 2026, 23:58 UTC
Goal
Determine a repeatable approach for preserving members that are accessed only through reflection, JSON serialization, dependency injection, or XAML when the Xamarin.Android project is built with the Full linker mode (AndroidLinkMode=Full) for release configurations.
Constraints
The Full linker aggressively removes unused managed code, which reduces APK size but can cause MissingMethodException or TypeLoadException at runtime for reflection‑dependent libraries. Preservation hints such as [Android.Runtime.Preserve] attributes, a link.xml descriptor, or assembly‑level exclusion are available, yet their coverage for third‑party bindings and native interop remains unclear. Debug builds typically use None, so failures surface only in release artifacts.
Open Questions
Which preservation mechanism—attributes, link.xml, or assembly exclusion—offers the most maintainable coverage for third‑party libraries? How can teams verify that all reflection‑dependent code paths survive Full linking without exhaustive manual testing? Are there documented limits on the linker’s ability to analyze native interop references?