getting error MSB4018: The "LinkAssemblies" task failed unexpectedly. for Xamarin Android in Visual Studio 2015

586 views Asked by At

I'm getting this error on Release build when I use an obfuscator (.NET Reactor):

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: System.ArgumentException: Empty name

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.Mixin.CheckName(String name)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.ModuleDefinition.GetType(String namespace, String name)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.MetadataResolver.GetTypeDefinition(ModuleDefinition module, TypeReference type)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.MetadataResolver.GetType(ModuleDefinition module, TypeReference reference)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.ModuleDefinition.Resolve(TypeReference type)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Cecil.TypeReference.Resolve()

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Linker.Steps.SweepStep.ResolveAllTypeReferences(AssemblyDefinition assembly)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Linker.Steps.SweepStep.Process()

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Linker.Steps.BaseStep.Process(LinkContext context)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Mono.Linker.Pipeline.Process(LinkContext context)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute()

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1586,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

I'm using Visual Studio 2015 with Xamarin extension for Visual Studio v4.2.2.11 (file Xamarin.VisualStudio_4.2.2.11.msi), Xamarin Android v7.0.2.42, MSBuild 2015 and .NET Reactor. Project is setup to use .NET FX v4.6.1 and Android Target v5.1 (API 22) and minimum version v4.4 (API 19).

Since I was getting this on my project, I tested this by creating a blank Android project without any code added to it, just the code created by the new blank project (button click) so there are no references to DLLs or 3rd party components.

Regards,

NCruz

1

There are 1 answers

0
ncruz On

I credit this answer to Lex Li who pointed out that I should try to disable each of the obfuscation features, and see which triggers the linker issue. There are several command line switches that I use to activate certain obfuscation features like so: -suppressildasm 1 -obfuscation 1 -stringencryption 1 -antitamp 1 ..etc. At first, I removed/deleted them all from the command line but it still had the error. Then I put them all back and instead put 0 instead of 1 (-suppressildasm 0) to deactivate each function. The suppressildasm feature was the one causing the error.