I have a Xamarin.Android project that hangs when attempting to build the solution in Release configuration. I've narrowed it down to an issue with the linker - if the linker is switched off, it all builds fine.
I've done the build with higher verbosity and even using msbuild
from the command line (which suggests it's not an IDE problem), the result is the same. The build output just up to the point where it hangs reads:
Target _LinkAssembliesShrink:
Building target "_LinkAssembliesShrink" completely.
Input file "obj/Preview/linksrc/BondiToManly.Android.dll" is newer than output file "obj/Preview/link.flag".
Task "CreateProperty" skipped, due to false condition; ( '$(AndroidLinkTool)' != '' ) was evaluated as ( '' != '' ).
Task "MakeDir" skipped, due to false condition; ( '$(AndroidLinkTool)' != '' ) was evaluated as ( '' != '' ).
Using "LinkAssemblies" task from assembly "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Build.Tasks.dll".
Task "LinkAssemblies"
Processing resource linker descriptor: mscorlib.xml
Processing resource linker descriptor: Mono.Android.xml
Processing embedded resource linker descriptor: mscorlib.xml
Duplicate preserve in descriptor mscorlib.xml from Xamarin.Android.Build.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null of System.AppDomain (Nothing). Duplicate uses (Fields)
Duplicate preserve in descriptor mscorlib.xml from Xamarin.Android.Build.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null of System.AppDomainSetup (Fields). Duplicate uses (Fields)
Type Mono.ValueTuple has no fields to preserve
Type System.Reflection.Assembly has no fields to preserve
Type System.Reflection.Emit.ByRefType has no fields to preserve
Type System.Reflection.Emit.PointerType has no fields to preserve
And it really hangs, like a thread deadlock or something. There's no way to cancel the build, you need to just quit the IDE (similarly, ^C in the terminal does nothing either).
This only seems to affect this one Xamarin project I have (many others with similar configurations build fine). At this stage, I'm really just hoping to find a way to get visibility on what's going wrong.
Any hints would be appreciated.
This is not my solution, but the issue was raised and a workaround shared over at the issues list on the Xamarin Android GitHub project at https://github.com/xamarin/xamarin-android/issues/3852
The fix is to remove explicit support for Nullable reference types (
<Nullable>enable</Nullable>
) from the project file.For example, in my project file with three configuration/platform PropertyGroups, remove the lines with
<Nullable>enable</Nullable>
, like: