Asked by:
Snackbar Problem

Question
-
User43840 posted
Hi! I want to use Android.Support.Design.Widget.Snackbar with this code but I get this error: System.MissingMethodException: Method not found: 'Android.Runtime.JNIEnv.CallStaticObjectMethod'.
Snackbar s = Snackbar.Make(FindViewById(Resource.Id.snackbarPosition), "Salam", Snackbar.LengthShort); s.SetAction("Undo", delegate { }); s.Show();
and the layout:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <android.support.design.widget.CoordinatorLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:id="@+id/snackbarPosition"> </android.support.design.widget.CoordinatorLayout> </LinearLayout>
Is this problem for library or my code has problem?
Wednesday, June 17, 2015 6:06 AM
All replies
-
User209 posted
Full stack trace please.
Wednesday, June 17, 2015 2:24 PM -
User43840 posted
Excuse me for my late reply
` -------------------Full Stack Trace 06-18 12:14:45.598 D/Mono (29517): Searching for 'androidlogprint'. 06-18 12:14:45.598 D/Mono (29517): Probing 'androidlogprint'. [0:] -------------------Full Stack Trace 06-18 12:14:45.598 D/Mono (29517): Found as '_androidlog_print'. 06-18 12:14:45.599 I/mono-stdout(29517): -------------------Full Stack Trace [0:] System.MissingMethodException: Method not found: 'Android.Runtime.JNIEnv.CallStaticObjectMethod'. 06-18 12:14:45.640 I/mono-stdout(29517): System.MissingMethodException: Method not found: 'Android.Runtime.JNIEnv.CallStaticObjectMethod'.
at Android.Support.Design.Widget.Snackbar.Make (Android.Views.View p0, System.String p1, Int32 p2) [0x00000] in
:0 at App1.MainActivity+<>cDisplayClass1. b 0 (System.Object param0, System.EventArgs param1) [0x00002] in f:\Android C#\App1\App1\MainActivity.cs:30 [0:] System.MissingMethodException: Method not found: 'Android.Runtime.JNIEnv.CallStaticObjectMethod'. at Android.Support.Design.Widget.Snackbar.Make (Android.Views.View p0, System.String p1, Int32 p2) [0x00000] in:0 at App1.MainActivity+<>cDisplayClass1. b 0 (System.Object param0, System.EventArgs param1) [0x00002] in f:\Android C#\App1\App1\MainActivity.cs:30 06-18 12:14:45.640 I/mono-stdout(29517): at Android.Support.Design.Widget.Snackbar.Make (Android.Views.View p0, System.String p1, Int32 p2) [0x00000] in:0 06-18 12:14:45.641 I/mono-stdout(29517): at App1.MainActivity+<>cDisplayClass1. b 0 (System.Object param0, System.EventArgs param1) [0x00002] in f:\Android C#\App1\App1\MainActivity.cs:30 `Thursday, June 18, 2015 7:46 AM -
User83624 posted
Any further luck on making this work?? I have just tried but get an exception saying linear layout cannot be cast to snack bar layout exception. I have not added an action to the snack bar, just tried to display it. code was identical.
Thursday, July 2, 2015 6:02 AM -
User75714 posted
I ran into the above issue too. (linear layout cannot be cast to snack bar layout). The weird thing is that, if I run my app in Release mode, it works perfectly. It only occurs in Debug mode.
Monday, July 6, 2015 9:52 AM -
User75714 posted
@JoshuaF A simple Clean/Rebuild fixed this issue. Can't believe this wouldn't work a couple of days ago, when I tried that too...
Monday, July 6, 2015 10:34 AM -
User43840 posted
I don't know how do you get that error?!!! I still have System.MissingMethodException error and couldn't solve it. No casting error! Changing to release mode didn't work for me.
Monday, July 6, 2015 11:13 AM -
User83624 posted
Thanks so much for your comments guys, i actually ended up solving the issue soon after posting as per usual and forgot to reply. What my issue was to get the casting error was i had the android target sdk the same as the compile sdk which was 22. As soon as i made the target sdk 21, (didnt change the compile sdk) it was all ok. give that a try
Tuesday, July 7, 2015 5:22 AM -
User376901 posted
The only thing that works for me is to Restore packages of the android project then Clean/Rebuild. However, I have to do this every Nth time (seems to be random or at least did not find the pattern yet), so I would NOT call it A SOLUTION. Can anybody from the Xamarin team clear this issue up? Googling doesn't seem to return much and it really does interfere with my work.
Tuesday, August 28, 2018 8:11 AM