Yaza
Yaza

Reputation: 325

“Link Assemblies” task failed unexpectedly issue while building release version of app in Xamarin

I want to release my android app. When I try to build it, it gives me the following error:

Severity    Code    Description Project File    Line    Suppression State
Error       The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Reference to metadata item 'Mono.Security.Interface.MonoTlsProviderFactoryDelegate' (defined in 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065') from 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve Mono.Security.Interface.MonoTlsProviderFactoryDelegate
   at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
   at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
   at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference)
   at Mono.Linker.Steps.MarkStep.InitializeFields(TypeDefinition type)
   at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
   at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
   at Mono.Linker.Steps.MarkStep.Initialize()
   at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute()
   --- End of inner exception stack trace ---
   at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
   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() TOPAPP.Droid    

I have deleted the xamarin.ios reference in the app.droid but that didn't work. Any suggestions? I also tried setting the android versions to what ever I found on the internet. I also tried updating PCL version but still nothing. Am I missing something?

EDIT: In my project I also have a portable library linked to the android project with ios code in it.

Upvotes: 2

Views: 1857

Answers (1)

Jon Douglas
Jon Douglas

Reputation: 13176

I'm not sure why you might have Xamarin.iOS referenced in your Xamarin.Android project. But the issue is that you have some type of reference there when it shouldn't be. Your PCL should not have any Native code inside it.

The Linker does not do any work when it's a Debug configuration. When you change to Release it will try to find assemblies that you do not use and strip them out. For some reason you have an iOS assembly in your Android project.

Check that your Xamarin.Android and PCL project do not reference Xamarin.iOS in anyway. The native projects should only be referencing the PCL(Which contains no Native Code inside)

Upvotes: 7

Related Questions