Xamarin.AndroidX 发布模式下的构建错误

Xamarin.AndroidX build error in release mode

我有一个用于 iOS 和 Android 的 Xamarin Forms 项目。 iOS 应用程序在调试和发布模式下构建,但 Android 应用程序不在发布模式下构建。我可以在 Debug 中构建并 运行 它很好,但是当我尝试将它存档以在 Visual Studio 中发布以用于 Mac.

时出现以下错误
Mono.Linker.LoadException: Error while processing references of 'MyApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Xamarin.AndroidX.Work.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Xamarin.AndroidX.Work.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
  at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x000ff] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs:172 
  at Mono.Linker.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x0008d] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00007] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
   --- End of inner exception stack trace ---
  at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00030] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Mono.Linker.LinkContext.ResolveReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00026] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00026] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x0003b] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
   --- End of inner exception stack trace ---
  at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x0005b] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Mono.Linker.Steps.LoadReferencesStep.ProcessAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00000] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Mono.Linker.Steps.BaseStep.Process (Mono.Linker.LinkContext context) [0x00025] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Mono.Linker.Pipeline.ProcessStep (Mono.Linker.LinkContext context, Mono.Linker.Steps.IStep step) [0x0000d] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x0000f] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at MonoDroid.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline, Mono.Linker.LinkContext context) [0x00000] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at MonoDroid.Tuner.Linker.Process (MonoDroid.Tuner.LinkerOptions options, Mono.Linker.ILogger logger, Mono.Linker.LinkContext& context) [0x00071] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Xamarin.Android.Tasks.LinkAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res) [0x001dd] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Xamarin.Android.Tasks.LinkAssemblies.RunTask () [0x0001b] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 
  at Xamarin.Android.Tasks.AndroidTask.Execute () [0x00000] in <4f0a19c9d0ec417f9e44b588fd30d062>:0 

最初我有 Android 应用程序针对 Android 9 Oreo(API 版本 28),但是当我将它上传到 Google Play 商店时,我收到了以下错误:

Upload failed
Your app currently targets API level 27 and must target at least API level 28 to ensure it is built on the latest APIs optimized for security and performance. Change your app's target API level to at least 28.

因此,我尝试将目标版本设置为 Android 10(API 版本 29),但随后出现弃用错误,因此我将目标版本改回 9(API Version 28) 由于上述错误,现在我无法在 Release 模式下构建。

这是我的 Android 应用设置:

我最终删除了解决方案中项目的 bin 和 obj 文件夹中的所有内容,重新启动 Visual Studio 并且能够构建和存档 Android 应用程序,但也没有得到来自 Google Play 的错误消息。一定是缓存了错误版本的库。