Forum Xamarin.Android

error MSB4018: The "LinkAssemblies" task failed unexpectedly.

NBCruzNBCruz USMember ✭✭

I'm getting this error on Release build:

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 Android v4.2.2.11 (file Xamarin.VisualStudio_4.2.2.11.msi) with 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).

Answers

  • Richy_GeorgeRichy_George INMember ✭✭✭

    Try to increase the heap size to 1G or try to release without linking

  • NBCruzNBCruz USMember ✭✭
    edited February 2017

    Richy,

    I increased the 'Java Max Heap Size' to 1G but it still has the same error. I also tried by setting linking to 'None' - the app builds and I'm able to create the apk file but when deployed to the device/phone it launches but the main screen or activity doesn't load - the app shows on the phone's screen and it has the name of the app at the header or top of the screen but the screen's UI or view does not show. This blank Android project has the default 'Hello World' button that shows the number of clicks, and that doesn't show. Then after several seconds the app disappears from the screen like it abended and closed.

    One thing to note is that in the Output log, right before/above the error stack are these two log entries:

    1>    Processing: obj\Release\res\layout\main.xml
    1>    Processing: obj\Release\res\values\strings.xml
    

    then

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

    I looked at the strings.xml file and it's simply this:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="Hello">Hello World, Click Me!</string>
        <string name="ApplicationName">TestAppFXv461</string>
    </resources>
    

    The last two entries in the Output log are these:

    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.<ExecuteInstantiatedTask>d__26.MoveNext()
    

    Would these tasks have anything to do with processing the strings.xml file?

  • SergeAnSergeAn ATMember

    Hi Naz, do you have some solution to this issue already? I've been struggling with this already since couple days as well..
    Thanks!

  • NBCruzNBCruz USMember ✭✭

    Serge - I've tried different workarounds but no solution yet.

  • kio21kio21 USMember
    edited May 2017

    Hello, any progress on this? Has the same error.
    Using Visual Studio Community 2017 for Mac, version 7.0 (build 3146), Mono 5.0.0.100

    Error MSB4018: The "LinkAssemblies" task failed unexpectedly.
    System.NullReferenceException: Object reference not set to an instance of an object

  • darrell.tunnelldarrell.tunnell USMember ✭✭
    edited June 2017

    Same issue. Using Xamarin.Android (7.3.1.2) and visual studio 2015 (14.0.25431.01 Update 3). I am building an Xamarin Unit Test app, Targeting (compile with) v7.0. Linking "Sdk Assemblies Only". The project builds from within visual studio ok. I get this error when trying to build using msbuild: msbuild "MyProj.csproj" /t:SignAndroidPackage /p:Configuration=Release

  • XigmondXigmond USMember ✭✭✭

    Im also having the same problem ( release mode / linking sdk assemblies )

    anyone has a solution?

  • XigmondXigmond USMember ✭✭✭

    downgrading the Xamarin.forms to the previous version works !!

Sign In or Register to comment.