Xamarin.Forms MissingMethodException: 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found
Asked Answered
B

4

9

I have followed everything from the following link: https://developer.xamarin.com/guides/xamarin-forms/user-interface/navigation/master-detail-page/ The code I wrote can be found here: http://github.com/foyzulkarim/XamarinFormsDrawer I successfully deployed the same project in my Windows 10 Local machine using UWP project, but whenever I want to deploy in Emulator, or in my device, it is throwing the following exception.

System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found.
09-17 17:16:33.636 D/Mono    (10472): DllImport attempting to load: '/system/lib/liblog.so'.
09-17 17:16:33.637 D/Mono    (10472): DllImport loaded library '/system/lib/liblog.so'.
09-17 17:16:33.637 D/Mono    (10472): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
09-17 17:16:33.637 D/Mono    (10472): Searching for '__android_log_print'.
09-17 17:16:33.637 D/Mono    (10472): Probing '__android_log_print'.
09-17 17:16:33.637 D/Mono    (10472): Found as '__android_log_print'.
09-17 17:16:33.645 I/MonoDroid(10472): UNHANDLED EXCEPTION:
09-17 17:16:33.658 I/MonoDroid(10472): System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found.
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001f] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Platform.cs:282 
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\RendererFactory.cs:10 
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.AddChild (Xamarin.Forms.Page page, System.Boolean layout) [0x00015] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:248 
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x00089] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:237 
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.InternalSetPage (Xamarin.Forms.Page page) [0x0009b] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:336 
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.SetMainPage () [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:410 
09-17 17:16:33.659 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.LoadApplication (Xamarin.Forms.Application application) [0x00158] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:123 
09-17 17:16:33.659 I/MonoDroid(10472):   at App1.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00018] in C:\Users\foyzu\Source\Github\XamarinForms\XamarinFormsDrawer\App1\App1\App1.Droid\MainActivity.cs:23 
09-17 17:16:33.659 I/MonoDroid(10472):   at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <71c3e52f1b484794bca1cdfb1b8b1fdb>:0 
09-17 17:16:33.659 I/MonoDroid(10472):   at (wrapper dynamic-method) System.Object:1a87dfa6-a154-49b0-925d-8ddad74d97cf (intptr,intptr,intptr)
09-17 17:16:33.677 W/art     (10472): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
09-17 17:16:33.681 D/Mono    (10472): DllImport searching in: '__Internal' ('(null)').
09-17 17:16:33.681 D/Mono    (10472): Searching for 'java_interop_jnienv_throw'.
09-17 17:16:33.681 D/Mono    (10472): Probing 'java_interop_jnienv_throw'.
09-17 17:16:33.681 D/Mono    (10472): Found as 'java_interop_jnienv_throw'.
An unhandled exception occured.

09-17 17:16:34.399 E/mono    (10472): 
09-17 17:16:34.399 E/mono    (10472): Unhandled Exception:
09-17 17:16:34.399 E/mono    (10472): System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found.
09-17 17:16:34.399 E/mono-rt (10472): [ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found.
referenceTable GDEF length=814 1
referenceTable GSUB length=11364 1
referenceTable GPOS length=47302 1

enter image description here

enter image description here

Bawdry answered 17/9, 2016 at 11:33 Comment(1)
open Nuget Packet Manager and uninstall all packet and then install again..Berezina
B
19

The solution is, I needed to update the package, only the Xamarin.Forms package. Like the below image.

Follow the red circle at the bottom, only update the Xamarin.Forms

After update, the packages.config file should be like below

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Forms" version="2.3.2.127" targetFramework="monoandroid60" />
</packages>

And ignore the rest of the packages like below. Ignore these updates

Bawdry answered 17/9, 2016 at 12:33 Comment(1)
Great, it just need to restart the Visual StudioAdelina
C
1

Just update your nuget-packages to latest (Xamarin.forms too)

clean solution

close the visualstudio

delete all .zip files in:

C:\Users[YouUserName]\AppData\Local\Xamarin\zips

Restart visualstudio and recompile :) It will download those .zip files again (it may take a few minutes). Those zips includes related android support libraries. So it will download the true ones (your referenced xamarin.forms version related).

Comment answered 12/10, 2016 at 13:57 Comment(0)
B
0

Updating the Xamarin.Forms nuget package didn't work for me. In my case, an update of Android Studio was necessary to make Xamarin.Forms work with Visual Studio. After updating, restart Android Studio and do look for updates again and apply them if they get found. You need to keep repeating this, because not all updates get installed in one go. This was my case, at least.

I suppose this worked, because Android Studio contains the Android SDK or some other components which Visual Studio or Xamarin need.

Burgoyne answered 5/10, 2016 at 11:0 Comment(2)
this question is about Visual Studio, not Android Studio. though both has the word 'studio' :)Bawdry
It seems I need to edit my post to avoid further confusion: updating Android Studio made Xamarin.Forms in Visual Studio work again. I suppose that it's because Android Studio contains the Android SDK or some other components which Visual Studio or Xamarin need.Burgoyne
R
0

Most of Cases You need to update the Xamarin.Forms Package to the latest Version

on all your projects( To avoid Other Exceptions)

For Portable, .Driod,.IOS and for Windows Phone if exist, then it is mandatory to clean your solution and close visual studio and open it again, Finlay every thing will be fine.

But On Some Cases you need to downgrade your Xamarin.Forms Package to 2.3 instead 2.5.0.121934

Rapallo answered 27/9, 2017 at 8:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.