Repository navigation
Description
Description
Building a .NET Android / MAUI Android app with CoreCLR (the default runtime in .NET 11) in Release configuration fails with:
error XALNS7015: System.NotSupportedException: Writing mixed-mode assemblies is not supported
at Mono.Cecil.ModuleWriter.Write(...)
at Mono.Cecil.AssemblyDefinition.Write(...)
at Xamarin.Android.Tasks.SaveChangedAssemblyStep.ProcessAssembly(...)
at Xamarin.Android.Tasks.AssemblyModifierPipeline.RunPipeline(...)
at Xamarin.Android.Tasks.AssemblyModifierPipeline.RunTask()
at Microsoft.Android.Build.Tasks.AndroidTask.Execute()
This failure is already documented in the test suite but suppressed:
// BuildTest.cs - SimilarAndroidXAssemblyNames
Assert.Ignore("CoreCLR: fails because of a Mono.Cecil lack of support");CoreCLR is the default Android runtime starting in .NET 11, so this is now a first-class failure for Release builds.
Steps to Reproduce
- Create a .NET MAUI Android app targeting
net11.0-android - Reference a NuGet package containing a Java binding assembly that has a concrete
Java.Lang.Objectsubclass missing an abstract interface method implementation — for example:<PackageReference Include="Microsoft.Intune.Maui.Essentials.android" Version="11.5.1" />
- Build Release for
android-arm64:dotnet build -c Release -r android-arm64
Expected Behavior
Build succeeds.
Actual Behavior
Build fails with XALNS7015.
Root Cause
The pipeline in _LinkAssembliesNoShrink has two steps relevant here:
1. FixAbstractMethodsStep — inspects each Java.Lang.Object subclass in binding assemblies and injects stub methods (throwing AbstractMethodError) for any abstract interface methods that are not yet implemented. It sets context.IsAssemblyModified = true when it does so.
2. SaveChangedAssemblyStep — if IsAssemblyModified, calls assembly.Write(destination, writerParameters) via Mono.Cecil.
With MonoVM, the SourceFiles passed to _LinkAssembliesNoShrink are plain IL assemblies. With CoreCLR (new in .NET 11), _LinkAssembliesNoShrinkInputs feeds R2R-compiled assemblies from obj/…/R2R/ as SourceFiles. When FixAbstractMethodsStep needs to patch such an assembly, SaveChangedAssemblyStep fails because Mono.Cecil cannot write R2R assemblies (the ILONLY PE flag is cleared; the file contains embedded native ARM64 code).
Most binding assemblies (e.g. MSAL) already have all abstract methods implemented and pass through unmodified (IsAssemblyModified = false), hitting the safe CopyIfChanged path. The failure only surfaces for assemblies where FixAbstractMethods actually finds and injects a stub — in this case, IMAMServiceAuthenticationCallbackExtendedInvoker in MAMSDKBinding.dll was missing its AcquireToken implementation.
Environment
- .NET SDK:
11.0.100-preview.2.26159.112 Microsoft.Android.Sdk.Darwin:36.1.99-preview.2.154- Reproducer NuGet:
Microsoft.Intune.Maui.Essentials.android11.5.1 - Configuration: Release,
android-arm64, CoreCLR - macOS
Activity
Fix XALNS7015: run FixAbstractMethodsStep before R2R in non-trimmed C…
Fix XALNS7015: run _LinkAssembliesNoShrink before crossgen2 in inner …
Fix XALNS7015: run _LinkAssembliesNoShrink before R2R in non-trimmed …
michaldobrodenka commentedon Apr 23, 2026
I have this problem with net10-android36 when
<UseMonoRuntime>false</UseMonoRuntime>jonathanpeppers commentedon Aug 12, 2026
Current status as of August 12, 2026: this is not fixed in
mainor in a released build.fix/11025-r2r-abstract-methods-v2branch also remains unmerged and has no active PR.mainstill runs_LinkAssembliesNoShrinkusing@(ResolvedAssemblies)without ordering it before_PrepareForReadyToRunCompilation.SimilarAndroidXAssemblyNamesandAndroidAddKeepAlivesare still skipped withAssert.Ignore ("CoreCLR: fails because of a Mono.Cecil lack of support").Since CoreCLR has already shipped and is now the default runtime, this is a shipped-product issue for non-trimmed Release/CoreCLR builds whenever a binding assembly requires
FixAbstractMethodsSteprewriting. The trigger is narrow, but affected packages fail reliably with XALNS7015. We should revive/rebase the fix, restore the skipped tests, and consider servicing the affected shipped versions.fix(android): disable ReadyToRun due to dotnet/android#11025
[build] Disable CoreCLR ReadyToRun without trimming (dotnet#12445)