The “LinkAssemblies” task failed unexpectedly

谁都会走 提交于 2019-11-30 10:46:06

Apparently, this is a known issue: Xamarin Forms needs the TargetAndroidVersion to be 21. (In the config GUI, this is entitled "Compile using Android version:")

In my case problem occured becasue of adding Xamarin.ios.dll to Portable Project references. I have removed that reference and it works now

In my case the problem was referenced dll Xamarin.iOS in the pcl project. Linking does not work for this assembly. Removing the reference fixed the issue.

I changed the Linker properties > Linking from Sdk Assemblies Only to Sdk and User Assemblies for the Release configuration.

I also experienced the same problem. After series of trial and errors i found a solution.

In your Manifest set Target Android Version to Android 7.1 (API Level 25 Nougat) or Higher. Set Compile Android Version to Android 7.1 as well.

I hope this helps

I fixed it downgrading the Xamarin.Android.Support.v4 to the 21.0.0 version in NuGet Package Manager. Hope that help you

I ended up getting this error after changing the Android target version to 9.0. What I noticed is that in the packages.config of the Android project, all the packages were still targeting monoandroid81 instead of monoandroid90.

I solved it by just reinstalling all NuGet packages. This can be done quite easily through the Package Manager Console in Visual Studio by entering:

Update-Package -Reinstall

I recommend taking a backup first, though.

After that all the packages were targeting the correct version and the compilation errors were gone.

I had a different root cause for the "LinkAssembliesTask failed" error.

I was upgrading NuGet packages, and messed up the references.

=====

Let's say I had two projects:

  1. NetStandardProject

    • Has a reference to Assembly1.

    • Assembly1 has a class of CoolGuy, with a CoolGuy.Flex() method.

  2. AndroidProject, which references NetStandardProject.

    • Has a reference to Assembly2.

    • Assembly2 has a class of CoolGuy, but no CoolGuy.Flex() method.

The linker was pulling in Assembly2, looking for CoolGuy.Flex(), then blew up with "LinkAssembliesTask failed", stating that it couldn't find the Flex() method. It couldn't because it was looking in the wrong assembly.

The NetStandard project compiled, because it was referencing Assembly1, and didn't really care what AndroidProject was referencing. It's built independently. But when the linker loaded Assembly2, it was using the "wrong" assembly.

I ended up sorta lucking out, and realized that one of the assemblies was unused, so I removed it, and the build succeeded.

Hope that helps someone down the line.

=====

Bonus: If you want to see which assembly it's choosing to search, let the build fail, then go to the {project}\obj{profile}{android_version}\android\assets folder, and find the dll. You will likely be able to verify that it's not there, and give you a starting point to understanding why it's failing.

Anish Manchappillil

In my chase I have changed the linker property ( Linker --> Linking ) to 'None'. I am using visual studio 2017 RC

Jus I changed linking from "NONE" to "sdk and users assembly" and I ran my solution, and the issue has been solved. after that you can change "sdk and users assembly" to "NONE" and run your project without any issue.

But the release file size may be will be change.

enter image description here

I´ve solved that changing Android Linker Behavior option in options > Android Builder > Linker from "Link sdk Assemblies Only" to "don't link".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!