无法在发布模式下构建Xamarin Android应用程序

时间:2019-02-20 07:25:13

标签: xamarin xamarin.forms

我正在尝试构建Xamarin Forms Android应用程序,但是它无法在Release模式下进行编译,而Debug可以正常工作。

错误详细信息:

  

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(5,5):   错误MSB4018:“ LinkAssemblies”任务意外失败。   Mono.Linker.Steps.XmlResolutionException:无法处理XML   说明:--->   Mono.Cecil.AssemblyResolutionException:无法解析程序集:   'Prism.Core,版本= 0.0.0.0,文化=中性,PublicKeyToken =空'   ---> Mono.Cecil.AssemblyResolutionException:无法解析程序集:'Prism.Core,Version = 0.0.0.0,Culture = neutral,   Mono.Cecil.BaseAssemblyResolver.Resolve上的PublicKeyToken = null   (Mono.Cecil.AssemblyName参考名称,Mono.Cecil.ReaderParameters   参数)[0x0015e]在   /Users/builder/data/lanes/6102/8255f42f/source/monodroid/external/xamarin-android/external/mono/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs:172   在Mono.Linker.AssemblyResolver.Resolve   (Mono.Cecil.AssemblyName参考名称,Mono.Cecil.ReaderParameters   参数)[0x0005c]在<947dd92f52fa43c1922f96c7b9774bdc>:0中   Mono.Linker.LinkContext.Resolve(Mono.Cecil.IMetadataScope范围)   <947dd92f52fa43c1922f96c7b9774bdc>中的[0x00007]:0-内部末端   异常堆栈跟踪---在Mono.Linker.LinkContext.Resolve   (Mono.Cecil.IMetadataScope范围)[0x00030]在   <947dd92f52fa43c1922f96c7b9774bdc>:0在   Mono.Linker.Steps.ResolveFromXmlStep.GetAssembly   (Mono.Linker.LinkContext上下文,Mono.Cecil.AssemblyNameReference   assemblyName)[0x00000]在<947dd92f52fa43c1922f96c7b9774bdc>:0中   Mono.Linker.Steps.ResolveFromXmlStep.ProcessAssemblies   (Mono.Linker.LinkContext上下文,System.Xml.XPath.XPathNodeIterator   迭代器)[0x00010]在<947dd92f52fa43c1922f96c7b9774bdc>:0中   Mono.Linker.Steps.ResolveFromXmlStep.Process()[0x00037]在   <947dd92f52fa43c1922f96c7b9774bdc>:0-内部异常结束   堆栈跟踪--在Mono.Linker.Steps.ResolveFromXmlStep.Process()   [0x000a9]在<947dd92f52fa43c1922f96c7b9774bdc>:0中   Mono.Linker.Steps.BaseStep.Process(Mono.Linker.LinkContext上下文)   [0x00010]在<947dd92f52fa43c1922f96c7b9774bdc>:0中   Mono.Linker.Pipeline.Process(Mono.Linker.LinkContext上下文)   [0x0001c]在<947dd92f52fa43c1922f96c7b9774bdc>:0中   MonoDroid.Tuner.Linker.Run(Mono.Linker.Pipeline管道,   Mono.Linker.LinkContext上下文)[0x00000]在   <947dd92f52fa43c1922f96c7b9774bdc>:0在   MonoDroid.Tuner.Linker.Process(MonoDroid.Tuner.LinkerOptions选项,   Mono.Linker.ILogger记录器,Mono.Linker.LinkContext和上下文)   [0x00071]在<947dd92f52fa43c1922f96c7b9774bdc>:0中   Xamarin.Android.Tasks.LinkAssemblies.Execute   (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res)[0x002d4]在   <947dd92f52fa43c1922f96c7b9774bdc>:0在   Xamarin.Android.Tasks.LinkAssemblies.Execute()[0x0021f]在   <947dd92f52fa43c1922f96c7b9774bdc>:0在   Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute   ()[0x00023] in   /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573   在Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask   (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,   Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,   Microsoft.Build.BackEnd.TaskHost taskHost,   Microsoft.Build.BackEnd.ItemBucket存储桶,   Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask)[0x001f6]   在   /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:784   (MSB4018)(VSTSBuild.Droid)

我还注意到,如果启用“使用共享的单声道运行时”,它也将以Release模式构建,但是如果禁用它,则在构建解决方案时会遇到问题。

1 个答案:

答案 0 :(得分:0)

好的,我发现问题出在LinkerSettings。以前,我的链接器设置是这样的:

bar(X x, Y y)

我更新至:

<linker>
    <assembly
        fullname="Prism.Core" />
    <assembly
        fullname="Prism.Forms" />
    <assembly
        fullname="Prism.Unity.Forms" />
    <assembly
        fullname="Prism.Plugin.Popups" />
</linker>

现在,App在发布模式下也可以正常运行。