Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.Forms Getting Mono.Linker.MarkException: Error processing method when compiling in release mode

I have a Xamarin.Forms (2.5.1.527436) application using VS2017 (15.7.1) on windows. The android project builds and runs fine under debug. However, when I build under release I get the following error:

Severity Code Description Project File Line Suppression State Error The "LinkAssemblies" task failed unexpectedly. Mono.Linker.MarkException: Error processing method: 'System.Void Xamarin.Forms.Pages.BaseDataSource/d__22::MoveNext()' in assembly: 'Xamarin.Forms.Pages.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Xamarin.Forms.Log::Warning(System.String,System.String) at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference) at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference) at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction) at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body) at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method) at Mono.Linker.Steps.MarkStep.ProcessQueue() --- End of inner exception stack trace --- at Mono.Linker.Steps.MarkStep.ProcessQueue() at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue() at Mono.Linker.Steps.MarkStep.Process() at Mono.Linker.Steps.MarkStep.Process(LinkContext context) at Mono.Linker.Pipeline.Process(LinkContext context) at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, 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.d__26.MoveNext() IRMobile.Android C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1812

I am linking "Sdk Assemblies Only", min android version is 5.1 (level 22) and target Android version is 8.1 (Level 27)

Any ideas?

like image 474
Mark Erickson Avatar asked May 18 '18 16:05

Mark Erickson


2 Answers

In my case after a bunch of research I just

  • Upgraded some nuget packages, in the 3 projects Forms, Android and iOS and this fixed the issue in release mode.

OR

  • Also changing the Linking to None fixed the issue without upgrading the packages but I think it is not recommended.
like image 133
Victor Hugo Terceros Avatar answered Sep 20 '22 13:09

Victor Hugo Terceros


I fixed this by updating Xamarin.Forms to the latest stable (v5.0.0.2196). As what I have observed, when I update the Xamarin.Forms, it also install the correct version of dependencies. This includes the correct version of Xamarin.AndroidX.RecyclerView that solves my problem.

like image 29
Jeremy James Sangutan Avatar answered Sep 21 '22 13:09

Jeremy James Sangutan