Bug 56702 - NullReferenceExcception in the linker
Summary: NullReferenceExcception in the linker
Status: RESOLVED DUPLICATE of bug 57645
Alias: None
Product: Android
Classification: Xamarin
Component: Linker ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Radek Doulik
URL:
Depends on:
Blocks:
 
Reported: 2017-05-21 11:31 UTC by Rob Lyndon
Modified: 2017-06-20 21:13 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 57645

Description Rob Lyndon 2017-05-21 11:31:09 UTC
The LinkAssemblies Task failed unexpectedly. This is happening on every Release build. Stack trace:

Error		The "LinkAssemblies" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Mono.Linker.Steps.ResolveFromAssemblyStep.ProcessLibrary(LinkContext context, AssemblyDefinition assembly)
   at Mono.Tuner.CustomizeActions.ProcessUserAssembly(AssemblyDefinition assembly)
   at Mono.Tuner.CustomizeActions.ProcessAssembly(AssemblyDefinition assembly)
   at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at MonoDroid.Tuner.Linker.Run(Pipeline pipeline, LinkContext context)
   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

Shared Runtime, ProGuard and Multi-Dex are all turned off.
Comment 1 Christoph Engels 2017-06-13 18:13:39 UTC
I have the same problem, exactly the same stack trace.

As a workaround, you can disable the linker in the "Android options" tab from the Droid project's settings, by setting the first dropdown to "None".
Comment 2 Radek Doulik 2017-06-16 11:55:55 UTC
What Xamarin.Android version do you use? Could you please attach a project which reproduces the issue?
Comment 3 Christoph Engels 2017-06-19 17:06:57 UTC
My specs:
Microsoft Windows 7 Professional (64-bit)
Version 6.1 (Build 7601: Service Pack 1)

Microsoft Visual Studio Professional 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01055

Xamarin           4.5.0.476
Xamarin.Android   7.3.1.2
Xamarin.iOS       10.10.0.35

Java 8 Update 131 (64-bit)
Java SE Development Kit 8 Update 131 (64-bit)

Android SDK Tools            25.2.5
Android SDK Platform-tools   26
Android SDK Build-tools      26
Android 8.0.0 SDK Platform   26.1
Android 7.1.1 SDK Platform   25.3 (+ Sources)

I updated from Xamarin 4.1.1.3 and Xamarin.Android 6.1.1.1.

Since my app is a corporate product, unfortunately I may not upload that project. Maybe I can strip it and the error still occurs. Hopefully you make it to fix the error without that though, because while that bug is there, the app is undistributable due to its enormous size of 100 MB when its previous version had 50 MB.
Comment 4 Christoph Engels 2017-06-20 15:24:55 UTC
I noticed the error in the Linker differs for "SdkOnly" setting:

SdkOnly
=======
System.InvalidOperationException: Sequence contains no matching element.
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at MonoDroid.Tuner.PreserveApplications.PreserveTypeProperty(CustomAttribute attribute, String property)
   at MonoDroid.Tuner.PreserveApplications.PreserveApplicationAttribute(CustomAttribute attribute)
   at MonoDroid.Tuner.PreserveApplications.ProcessAttributeProvider(ICustomAttributeProvider provider)
   at MonoDroid.Tuner.PreserveApplications.ProcessAssembly(AssemblyDefinition assembly)
   at Mono.Tuner.SubStepDispatcher.DispatchAssembly(AssemblyDefinition assembly)
   at Mono.Tuner.SubStepDispatcher.BrowseAssemblies(IEnumerable`1 assemblies)
   at Mono.Tuner.SubStepDispatcher.Process(LinkContext context)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at MonoDroid.Tuner.Linker.Run(Pipeline pipeline, LinkContext context)
   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Full
====
System.NullReferenceException: Object reference not set to an instance of an object.
   at Mono.Linker.Steps.ResolveFromAssemblyStep.ProcessLibrary(LinkContext context, AssemblyDefinition assembly)
   at Mono.Tuner.CustomizeActions.ProcessUserAssembly(AssemblyDefinition assembly)
   at Mono.Tuner.CustomizeActions.ProcessAssembly(AssemblyDefinition assembly)
   at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at MonoDroid.Tuner.Linker.Run(Pipeline pipeline, LinkContext context)
   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

None works.
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2017-06-20 21:13:39 UTC
With the help of some clues from another user, I have replicated the same stack trace from Comment 0 using a small from-scratch test case on Bug 57645.

I will tentatively mark this bug as a duplicate of that new bug to focus the investigation onto the report that includes a test case.

- If a candidate fix is found for Bug 57645 that does _not_ resolve the issue for the original reporter of this bug from Comment 0, then the reporter can set the "Status" of this bug report to REOPENED (and if possible, please do attach onto this bug report the particular assembly that causes the problem).

- For any other user (other than the reporter from Comment 0, such as the user in Comment 1), you will not be able to adjust the "Status" of this bug report, so if the eventual candidate fix for Bug 57645 does not resolve the issue for your particular scenario, please file a new bug report with as many details as possible [1] (ideally attaching the particular assembly that causes the problem if possible).

[1] https://developer.xamarin.com/guides/cross-platform/troubleshooting/questions/howto-file-bug/

Thanks in advance.

*** This bug has been marked as a duplicate of bug 57645 ***