" LinkAssemblies"任务意外失败| Xamarin发布版

时间:2018-01-16 17:09:25

标签: visual-studio xamarin xamarin.android

我正在使用Xamarin在Visual Studio中开发应用程序。我想在发布模式下构建以编译APK,以便我可以让朋友安装应用程序来测试我到目前为止所做的事情。

在发布模式下构建时,我收到以下错误:

Severity    Code    Description Project File    Line    Suppression State
Error       The "LinkAssemblies" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Mono.Linker.TypeReferenceExtensions.<GetMethods>d__4.MoveNext()
   at Mono.Linker.Steps.TypeMapStep.TryMatchMethod(TypeReference type, MethodDefinition method)
   at Mono.Linker.Steps.TypeMapStep.<GetBaseMethodsInInterfaceHierarchy>d__12.MoveNext()
   at Mono.Linker.Steps.TypeMapStep.MapVirtualInterfaceMethod(MethodDefinition method)
   at Mono.Linker.Steps.TypeMapStep.MapVirtualMethods(TypeDefinition type)
   at Mono.Linker.Steps.TypeMapStep.MapType(TypeDefinition type)
   at Mono.Linker.Steps.TypeMapStep.MapType(TypeDefinition type)
   at Mono.Linker.Steps.TypeMapStep.ProcessAssembly(AssemblyDefinition assembly)
   at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() PartyMe.Android         

谷歌搜索该问题有很多结果。他们都建议定位最新的Android SDK或API 21.我已经针对API 26(奥利奥)。还有一些人说要将Xamarin.Forms更新到最新版本,但我甚至没有使用Xamarin.Forms。

我也尝试过关闭/重新开放和清理/重建。

2 个答案:

答案 0 :(得分:0)

看起来它没有在您的解决方案中编译PCL / Shared项目 如果它是正在进行/正在使用Nuget包的一些引用的项目,我会清理解决方案,删除/bin&amp; /obj个文件夹并删除packages文件夹 否则,我会手动删除并重新插入PCL / Shared项目中的所有软件包引用。

答案 1 :(得分:0)

Visual Studio 2017 15.5.X版中存在一个错误,导致Xamarin.Android项目的链接器问题在发布模式下编译。我在15.5.5上测试过,问题依然存在。 不幸的是,到目前为止唯一的解决方法是恢复到VS2017 15.4.5

Xamarin论坛报道了同样的问题:  https://forums.xamarin.com/discussion/112783/the-linkassemblies-task-failed-unexpectedly?
如何恢复到旧版VS2017:https://docs.microsoft.com/en-us/visualstudio/productinfo/installing-an-earlier-release-of-vs2017