无法在发布模式下构建我的应用程序

Cant Build my App in Release mode

我的应用程序在调试模式下运行良好,但如果我想在发布版中构建它,我会收到以下错误:

Fehler  1   Unerwarteter Fehler bei der LinkAssemblies-Aufgabe.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'System.Void Xamarin.Forms.Element::set_AutomationId(System.String)' (defined in assembly 'ZXing.Net.Mobile.Forms, Version=2.1.47.0, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Xamarin.Forms.Element::set_AutomationId(System.String)
   bei Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
   bei Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
   bei Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
   bei Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
   bei Mono.Linker.Steps.MarkStep.ProcessQueue()
   bei Mono.Linker.Steps.MarkStep.Process()
   bei Mono.Linker.Steps.MarkStep.Process(LinkContext context)
   bei MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
   bei Mono.Linker.Pipeline.Process(LinkContext context)
   bei MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
   bei Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
   bei Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   bei Xamarin.Android.Tasks.LinkAssemblies.Execute()
   bei Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   bei Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()    Euroscola_App1

这个问题是从今天开始出现的,不知道是我下载了较新的Xamarin版本还是安装了ZXing包的原因

When the scope is different from the defining assembly, it usually means that the type is forwarded.

您在 Xamarin.Android 应用程序项目中启用了应用程序链接器,并且 Xamarin.FormsZXing.Net.Mobile.Forms 中转发的类型之间的版本不匹配。基本上 ZXing.Net.Mobile.Forms 是针对您当前在项目中使用的较旧版本的 Forms 编译的,如果程序集包含 C# 扩展,这是一个非常常见的问题。

两个选项,禁用整个应用程序的链接或仅禁用 Zing 程序集的链接:

要仅禁用该程序集的链接,请编辑您的 Android 应用程序项目 (.csproj) 并添加以下内容 < AndroidLinkSkip>:

<PropertyGroup>
    <AndroidLinkSkip>ZXing.Net.Mobile.Forms</AndroidLinkSkip>
</PropertyGroup>

参考:Xamarin Android 链接:AndroidLinkSkip