Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found

First I started developing Android with C# and Xamarin a week ago, and I'm stuck in this problem.

I already found several texts in Stack Overflow, but sadly didn't work.

To solve this problem, I took some steps.

  1. Before following things, when I start debug with Android_Accelerated_x86 (Android 6.0 -API 23), Visual Studio start find NavigationPageRenderer but is not there then I got message title above

  2. I installed and updated Packages using Android SDK Manager like following

  3. Then, I met message wrote on title

    System.MissingMethodException: Method
    Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found
    

    So, I struggled to find solution and

    1. I downloaded JDK 1.8.0_101 and changed path of Java Development Kit Location (in Tools > Option > Xamarin > Android Setting) but it didn't work. I've got the same message like title above.

    2. I went to Tools > NuGet Package Manager > Manage NuGet Packages for Solution and updated only Xamarin.Forms v2.3.2.127. Then I got 7 errors. One of them is

      Error: package android.support.v7.internal.widget does not exist.

  4. And I deleted the solution and make new project with Xamarin.Forms I got the Warnings message like

    IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled

    and... I got the message like title above.

  5. Also I got two 'Call Stack'

    0x23 in Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnAttachedToWindow at NavigationPageRenderer.cs
    
    0xA in Android.Views.View.n_OnAttachedToWindow at Android.Views.View.cs:
    

Please help me to solve this problem... Thanks a lot for your attention

like image 217
wallah Avatar asked Oct 17 '16 08:10

wallah


1 Answers

This issue happens because Google changed their support libraries in which you hookup this listener from SetDrawerListener() to AddDrawerListener(). Because of this you will need to ensure you're on the latest stable Xamarin.Forms. Previous versions of Xamarin.Forms that have a dependency on < Android.Support 23.3 will throw this error. You can refer to this commit for more details:

https://github.com/xamarin/Xamarin.Forms/commit/d9ed63f0add8345cf6ab1508b353dcbdacbcd97c

Ideally this should be fixed in Xamarin.Forms versions 2.2.0.31 and greater.

https://www.nuget.org/packages/Xamarin.Forms/

like image 84
Jon Douglas Avatar answered Oct 04 '22 20:10

Jon Douglas