38

I am trying to debug my Xamarin project. Framework and all packages are up to date. In iOS it works, but in Android NOT. How can I solve this problem:

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()       
Kaan Congar
  • 423
  • 1
  • 4
  • 4
  • Here is a similar issue that maybe can help you https://stackoverflow.com/questions/62132157/mono-linker-markexception-error-processing-method-system-void-plugin-localnot – Lucas Zhang Mar 17 '21 at 13:37

12 Answers12

76

I encountered this same problem after updating Visual Studio to 16.9.2 and updating the Android SDK.

The simple solution was to update the 'Xamarin.AndroidX.RecyclerView' Nuget package in the package manager. I Updated to the latest version (v1.1.0.8).

Zee
  • 913
  • 1
  • 8
  • 12
  • 15
    Thank you for your hint. My solution was to install 'Xamarin.AndroidX.RecyclerView' in the first place. – tschan Apr 30 '21 at 08:10
  • 3
    Same here. I didn't have that package installed. Installed it and it fixed the error. – Brien King Jun 03 '21 at 03:24
  • Indeed! Thanks! – Andrii Jul 17 '21 at 22:11
  • Off course for me it doesn't work!!! Never ever works in Xamarin... – user1034912 Sep 10 '21 at 06:33
  • @user1034912 perhaps you need one of the other packages explicitly installed per https://stackoverflow.com/a/67092611/1399272 - `Xamarin.AndroidX.Core`, `Xamarin.AndroidX.CustomView`, `Xamarin.AndroidX.Preference`, `Xamarin.AndroidX.RecyclerView`? – Bondolin Nov 08 '21 at 21:32
18

Same problem but i did not have 'Xamarin.AndroidX.RecyclerView' installed.

Solution: install in android project 'Xamarin.AndroidX.RecyclerView' and all work fine

Ricko..
  • 619
  • 6
  • 18
8

Zee's answer is correct. here is the explanation which can solve other similar issues. 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

1

I had this error. In my case, it was finally solved by removing the Xamarin.AndroidX.Legacy.Support.V4 NuGet, which was not needed anyway. I think the auto AndroidX migration put it in.

BillF
  • 1,034
  • 3
  • 13
  • 28
1

In my case, I didn't have to install any NuGet packages explicitly. I did remove Xamarin.AndroidX.AppCompat as it wasn't needed anymore, but what I think the real fix is: update Xamarin.Forms to be newer, greater than 5.0.0.2012.

That pulls in all sorts of newer versions of the AndroidX dependencies which seemed to resolve this problem.

bcr
  • 1,983
  • 27
  • 30
0

To me, the problem was with VS 16.9.3 and the release build, and the solution was to remove the dependency on Xamarin.AndroidX.AppCompat.AppCompatResources.

ZZZ
  • 2,752
  • 2
  • 25
  • 37
0

Same issue occurred for me today after I updated all my nuget packages, the issue was resolved when I cleaned and rebuilt the solution.

Jamshaid K.
  • 3,555
  • 1
  • 27
  • 42
0

For me the problem started when I upgraded to Xamarin.Firebase.Messaging v 121.1.0 - reverting to v121.0.1 resolved the problem - at least temporarily

Adrian Frielinghaus
  • 658
  • 1
  • 9
  • 15
0

My solution is installing: Xamarin.Google.Android.Material via Nuget

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
0

Update Visual Studio to the latest version and remove the Xamarin.AndroidX.RecyclerView nugget if you have it installed.

0

I solved this probles just updating the Android SDK version in: Android Project > Properties > Aplication > Compile Using Android Version and updating all the Xamarin dependendies with Nuget Manager. My last Android version was 11(S) and now is 12(R).

I hope this can help someone!

0

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 use types from that namespace are not being updated.

I solved this problem just by adding a few Nugets - Xamarin.AndroidX.Preference and Xamarin.AndroidX.Legacy.Preference.V14

Full list of versions:

<PackageReference Update="Xamarin.AndroidX.Biometric" Version="1.1.0.6" />
<PackageReference Update="Xamarin.AndroidX.CardView" Version="1.0.0.11" />
<PackageReference Update="Xamarin.AndroidX.ConstraintLayout" Version="2.1.1.2"  />
<PackageReference Update="Xamarin.AndroidX.Core" Version="1.6.0.3" />
<PackageReference Update="Xamarin.AndroidX.ExifInterface" Version="1.3.3.2" />
<PackageReference Update="Xamarin.AndroidX.Legacy.Preference.V14" Version="1.0.0.10" />
<PackageReference Update="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.10" />
<PackageReference Update="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.3.1.3" />
<PackageReference Update="Xamarin.AndroidX.Migration" Version="1.0.8" />
<PackageReference Update="Xamarin.AndroidX.Media" Version="1.4.3" />
<PackageReference Update="Xamarin.AndroidX.Preference" Version="1.1.1.11" />
<PackageReference Update="Xamarin.AndroidX.RecyclerView" Version="1.2.1.3" />

I hope this can help someone!

Anastasia
  • 452
  • 5
  • 7