Mono.Linker.MarkException:错误处理方法:'System.VoidAndroidX.RecyclerView.Widget.RecyclerView/LayoutManager

Mono.Linker.MarkException: Error processing method: 'System.Void AndroidX.RecyclerView.Widget.RecyclerView/LayoutManager

我正在尝试调试我的 Xamarin 项目。框架和所有包都是最新的。在 iOS 中有效,但在 Android 中无效。我该如何解决这个问题:

Mono.Linker.MarkException: Error processing method: 'System.Void AndroidX.RecyclerView.Widget.RecyclerView/LayoutManager::n_OnInitializeAccessibilityNodeInfo_Landroidx_recyclerview_widget_RecyclerView_Recycler_Landroidx_recyclerview_widget_RecyclerView_State_Landroidx_core_view_accessibility_AccessibilityNodeInfoCompat_(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)' in assembly: 'Xamarin.AndroidX.RecyclerView.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve AndroidX.Core.View.Accessibiity.AccessibilityNodeInfoCompat
   at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
   at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
   at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
   at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
   at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
   at Mono.Linker.Steps.MarkStep.ProcessQueue()
   --- End of inner exception stack trace ---
   at Mono.Linker.Steps.MarkStep.ProcessQueue()
   at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
   at Mono.Linker.Steps.MarkStep.Process()
   at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
   at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
   at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   at Xamarin.Android.Tasks.LinkAssemblies.RunTask()
   at Xamarin.Android.Tasks.AndroidTask.Execute()       

我在将 Visual Studio 更新到 16.9.2 并更新 Android SDK 后遇到了同样的问题。

简单的解决方案是更新包管理器中的“Xamarin.AndroidX.RecyclerView”Nuget 包。我更新到最新版本(v1.1.0.8)。

我有这个错误。就我而言,最终通过删除 Xamarin.AndroidX.Legacy.Support.V4 NuGet 解决了这个问题,无论如何都不需要。我认为自动 AndroidX 迁移已加入。

对我来说,问题出在 VS 16.9.3 和发布版本上,解决方案是删除对 Xamarin.AndroidX.AppCompat.AppCompatResources.

的依赖

Zee 的回答是正确的。 这是可以解决其他类似问题的解释。 https://github.com/xamarin/AndroidX/issues/283

jpobst commented on 1 Mar When resolving transitive dependencies, NuGet unfortunately picks the lowest dependency that meets the criteria. This means that fixes made to transitive dependencies often don't get picked up.

In this case the issue is the namespace misspelling (AndroidX.Core.View.Accessibiity) was corrected, however one (or more) of the packages that uses types from that namespace are not being updated.

You will need to make sure you are using the latest versions of these packages, which may require adding an explicit package reference to them:

Xamarin.AndroidX.Core
Xamarin.AndroidX.CustomView
Xamarin.AndroidX.Preference
Xamarin.AndroidX.RecyclerView

同样的问题,但我没有安装 'Xamarin.AndroidX.RecyclerView'。

解决方案:安装在 android 项目 'Xamarin.AndroidX.RecyclerView' 中,一切正常

今天我更新了所有 nuget 包后,我遇到了同样的问题,当我清理并重建解决方案时,问题得到了解决。

对我来说,当我升级到 Xamarin.Firebase.Messaging v 121.1.0 时问题开始了 - 恢复到 v121.0.1 解决了问题 - 至少是暂时的

我的解决方案是安装:Xamarin.Google.Android.Material 通过 Nuget