Bug 53064 - error MSB4018: The "LinkAssemblies" task failed unexpectedly.
Summary: error MSB4018: The "LinkAssemblies" task failed unexpectedly.
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Radek Doulik
URL:
Depends on:
Blocks:
 
Reported: 2017-03-05 20:07 UTC by NB
Modified: 2017-04-29 21:42 UTC (History)
5 users (show)

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


Attachments
non obfuscated DLL (6.00 KB, application/x-ms-dos-executable)
2017-03-05 22:03 UTC, NB
Details
obfuscated DLL (23.00 KB, application/x-ms-dos-executable)
2017-03-05 22:04 UTC, NB
Details
obfuscated DLL (linker set to 'Sdk Assemblies Only') (23.00 KB, application/x-ms-dos-executable)
2017-03-10 17:42 UTC, NB
Details


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 FIXED

Description NB 2017-03-05 20:07:51 UTC
I'm getting this error on Release build:

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

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

This is a simple new 'Blank App (Android)' project. There is no new code, just the default MainActivity.cs file and the default button click event that was automatically created.

I'm using Visual Studio 2015 with Xamarin Android v7.0.2.42 (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).

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?

Or maybe it's a problem with MSBuild or Mono.Cecil?
Comment 1 NB 2017-03-05 22:03:36 UTC
Created attachment 20137 [details]
non obfuscated DLL

When I set linking to 'None' - the app builds 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. 

I am attaching the DLLs for both Debug which is not obfuscated and Release which is obfuscated.
Comment 2 NB 2017-03-05 22:04:29 UTC
Created attachment 20138 [details]
obfuscated DLL

When I set linking to 'None' - the app builds 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. 

I am attaching the DLLs for both Debug which is not obfuscated and Release which is obfuscated.
Comment 3 Juan Marcelo Tondato 2017-03-06 12:59:23 UTC
Hi, it looks like a build error.
Moving the bug to Android for visibility from the right team.
Thanks for reporting!
Comment 4 NB 2017-03-09 05:03:45 UTC
Thanks. I hope someone can take a look at the two DLLs and see why the obfuscated one doesn't load the UI even when the MainActivity.cs class is not obfuscated (I used the [ObfuscationAttribute(Exclude = true, ApplyToMembers = true)] attribute to not obfuscate the main activity but it still does not load the main screen.
Comment 5 dean.ellis 2017-03-09 10:08:45 UTC
@Radek This looks like an linker issue, any chance you can take a look?
Comment 6 NB 2017-03-10 17:42:49 UTC
Created attachment 20272 [details]
obfuscated DLL (linker set to 'Sdk Assemblies Only')

The previous obfuscated DLL that I attached had the linker set to 'None'.
Comment 7 NB 2017-03-10 17:49:05 UTC
I just attached a DLL created with the linker set to 'Sdk Assemblies Only'. The build errors out with this setting. With the previous DLL, it doesn't error out and an apk is created, and I can install it on the device that I've attached to my PC (in Visual Studio the device is listed in the 'Start' dropdown). However, even with the linker set to 'None' the app seems not to enter into an activity or a UI. The app loads into the device screen but there is no UI. Then after a minute or two, the app disappears.
Comment 8 NB 2017-03-20 01:23:42 UTC
Can someone pls look into this?
Comment 9 NB 2017-04-05 20:19:06 UTC
Can someone pls look into this? I have uploaded two DLLs with the issue. Thanks.