Bug 29882 - Linker for Java Bindings
Summary: Linker for Java Bindings
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: 5.1
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Radek Doulik
URL:
Depends on:
Blocks:
 
Reported: 2015-05-08 11:06 UTC by Andy
Modified: 2017-10-04 15:12 UTC (History)
6 users (show)

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


Attachments

Description Andy 2015-05-08 11:06:32 UTC
Trying to compile my app in Release mode which contains a Java binding project.

I get the following error:

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018: Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item '!!0[] System.Array::Empty()' (defined in 'MyFleet.Appraiser.Bindings, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'MyFleet.Appraiser.Bindings, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve !!0[] System.Array::Empty()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessQueue()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.Process()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Mono.Linker.Pipeline.Process(LinkContext context)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    --- End of inner exception stack trace ---
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1292,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(1292,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__1.MoveNext()

I figured that I could set it to skip this assembly as it is only tiny but I still get this error.  Does skip assembly linking work for Java binding projects?
Comment 1 Jonathan Pryor 2015-05-08 12:50:53 UTC
I suspect that `'!!0[] System.Array::Empty()` is `System.Array.Empty<T>()`:

https://msdn.microsoft.com/en-us/library/dn906179(v=vs.110).aspx

What's odd is that Array.Empty<T>() is defined in .NET 4.6, which certainly shouldn't be used by a binding project, so why is that being referenced?

Something very weird is going on. Could you please attach the project which generates this error?
Comment 2 Jihun Lee 2015-05-18 22:27:45 UTC
I have the exact same error here.

I'm using rebound library from Facebook and having the same issue.

Notice that this error was happened right after I upgraded my Visual Studio to Visual Studio 2015 RC from Visual Studio 2015 Preview yesterday. One of my coworkers also had the same issue, so I guess this is related to Visual Studio 2015 RC.
Comment 3 Jihun Lee 2015-05-18 22:35:41 UTC
Plus, If I turn off the linker, I can build the project. ( Linker of referencing Android project ). Guess that the building issue is raised by linker since it cannot find "System.Array::Empty()"?

And, one weird thing is that if I set "Compile using Android Version" of my rebound binding library to "API Level 21 Xamarin Android v5.0 support" from "Use latest platform (API Level 21 Xamarin Android v5.0 support)", the project is build-able while nothing is changed actually.
Comment 4 Radek Doulik 2015-06-09 10:27:37 UTC
Andy, Jihun, could you please attach a sample project which has this issue?
Comment 5 Andy 2015-06-09 11:15:51 UTC
My problem was fixed when I changed the target version in the Bindings library from use latest to a specific API level.  It is currently set at API Level 19.  Don't know if that helps?
Comment 6 milen 2015-08-05 11:56:12 UTC
Thank you for the workaround Andy. Working with universal-image-loader-1.9.0.jar and changing the target version in the bindings lib helped me resolve the issue.
Comment 7 milen 2015-08-06 03:56:56 UTC
Thank you for the workaround Andy. Working with universal-image-loader-1.9.0.jar and changing the target version in the bindings lib helped me resolve the issue.
Comment 8 Alexandre Chohfi 2016-03-22 22:20:59 UTC
Having the same issue reported by users of my binding lib:
https://github.com/azchohfi/Crashlytics.Droid/issues/1
I can confirm that the workaround actually worked.
Comment 9 Jon Douglas [MSFT] 2017-10-04 15:12:50 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Android. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.

Note You need to log in before you can comment on or make changes to this bug.