更新到Xamarin.Forms 3.4.0.1009999后,尝试在发布模式下运行应用程序时出现以下错误-The "LinkAssemblies" Task Failed Unexpectedly
我已经搜索了此错误,并看到多个线程在此问题上,但是它们都是xamarin的早期版本,因此建议的解决方案似乎都不起作用。
我尝试过的是:
linker behaviour
(将其关闭)实际上是可行的,但是无法使用庞大的应用程序。从Xamarin.Android项目中删除并重新添加Xamarin.Forms包
日志:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(5,5): Error MSB4018: The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'Android.Views.ScaleGestureDetector Xamarin.Forms.Platform.Android.GestureManager::InitializeScaleDetector()' in assembly: 'Xamarin.Forms.Platform.Android.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.Support.V4.View.ScaleGestureDetectorCompat::SetQuickScaleEnabled(Android.Views.ScaleGestureDetector,System.Boolean)
at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod (Mono.Cecil.MethodReference reference) [0x00013] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Mono.Linker.Steps.MarkStep.MarkMethod (Mono.Cecil.MethodReference reference) [0x0004a] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Mono.Linker.Steps.MarkStep.MarkInstruction (Mono.Cecil.Cil.Instruction instruction) [0x00040] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Mono.Linker.Steps.MarkStep.MarkMethodBody (Mono.Cecil.Cil.MethodBody body) [0x00098] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00162] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x0001b] in <947dd92f52fa43c1922f96c7b9774bdc>:0
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00047] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue () [0x0000a] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Mono.Linker.Steps.MarkStep.Process () [0x00102] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x0000d] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at MonoDroid.Tuner.MonoDroidMarkStep.Process (Mono.Linker.LinkContext context) [0x0000b] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x0001c] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at MonoDroid.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline, Mono.Linker.LinkContext context) [0x00000] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at MonoDroid.Tuner.Linker.Process (MonoDroid.Tuner.LinkerOptions options, Mono.Linker.ILogger logger, Mono.Linker.LinkContext& context) [0x00071] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Xamarin.Android.Tasks.LinkAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res) [0x002d4] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at Xamarin.Android.Tasks.LinkAssemblies.Execute () [0x0021f] in <947dd92f52fa43c1922f96c7b9774bdc>:0
at 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
at 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 bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:784 (MSB4018) (LoyaltyWorx.Android)
我希望该项目能够像以前的Xamarin.Forms一样在设备上运行,而不必更改链接器行为并显着增加应用程序的大小。
答案 0 :(得分:2)
将Xamarin.Android.Support库更新到v27。这通常可以解决问题。不要忘了清理和构建,可能会重新启动Visual Studio