Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Snackbar issue (only in debug mode)

I am having an issue with the Snackbar in the android support design library. The weird thing is, that it only occurs when I run my app in Debug mode, in Release mode it all works perfectly.

Does Anyone have an idea on this issue? It seems to be a bug in the Support library.

Code

using (var snackbar = Snackbar.Make(View, "Nieuwe order aangemaakt", Snackbar.LengthLong).SetAction("OK", v => { }))
    snackbar.Show();

Exception

07-06 11:47:50.414 I/MonoDroid(13296): Java.Lang.ClassCastException: Exception of type 'Java.Lang.ClassCastException' was thrown. 07-06 11:47:50.414 I/MonoDroid(13296): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () 07-06 11:47:50.414 I/MonoDroid(13296): at OverAllField.XamarinAndroid.Fragments.Planning.PlanningFragment.FloatingActionButton_Click (object,System.EventArgs) [0x00001] in c:\Development\Apps\FieldService-Tablet\OverAllF07-06 11:47:50.414 I/MonoDroid(13296): at Android.Runtime.JNIEnv.CallStaticObjectMethod (intptr,intptr,Android.Runtime.JValue*) [0x00064] in /Users/builder/data/lanes/1502/24855232/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1301 07-06 11:47:50.414 I/MonoDroid(13296): at Android.Support.Design.Widget.Snackbar.Make (Android.Views.View,Java.Lang.ICharSequence,int) 07-06 11:47:50.414 I/MonoDroid(13296): at Android.Support.Design.Widget.Snackbar.Make (Android.Views.View,string,int) 07-06 11:47:50.414 I/MonoDroid(13296): at OverAllField.XamarinAndroid.Fragments.Planning.PlanningFragment.FloatingActionButton_Click (object,System.EventArgs) [0x00001] in c:\Development\Apps\FieldService-Tablet\OverAllField.XamarinAndroid\OverAllField.Android\Fragments\Planning\PlanningFragment.cs:74 07-06 11:47:50.414 I/MonoDroid(13296): at Android.Views.View/IOnClickListenerImplementor.OnClick (Android.Views.View) [0x0000d] in /Users/builder/data/lanes/1502/24855232/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:1923 07-06 11:47:50.414 I/MonoDroid(13296): at Android.Views.View/IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1502/24855232/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:1888 07-06 11:47:50.414 I/MonoDroid(13296): at (wrapper dynamic-method) object.84d16582-f149-4133-af10-0f21d61ca331 (intptr,intptr,intptr) 07-06 11:47:50.414 I/MonoDroid(13296): --- End of managed exception stack trace --- 07-06 11:47:50.414 I/MonoDroid(13296): java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.support.design.widget.Snackbar$SnackbarLayout 07-06 11:47:50.414 I/MonoDroid(13296): at android.support.design.widget.Snackbar.(Snackbar.java:119) 07-06 11:47:50.414 I/MonoDroid(13296): at android.support.design.widget.Snackbar.make(Snackbar.java:140) 07-06 11:47:50.414 I/MonoDroid(13296): at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method) 07-06 11:47:50.414 I/MonoDroid(13296): at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:29) 07-06 11:47:50.414 I/MonoDroid(13296): at android.view.View.performClick(View.java:4754) 07-06 11:47:50.414 I/MonoDroid(13296): at android.view.View$PerformClick.run(View.java:19605) 07-06 11:47:50.414 I/MonoDroid(13296): at android.os.Handler.handleCallback(Handler.java:733) 07-06 11:47:50.414 I/MonoDroid(13296): at android.os.Handler.dispatchMessage(Handler.java:95) 07-06 11:47:50.414 I/MonoDroid(13296): at android.os.Looper.loop(Looper.java:146) 07-06 11:47:50.414 I/MonoDroid(13296): at android.app.ActivityThread.main(ActivityThread.java:5748) 07-06 11:47:50.414 I/MonoDroid(13296): at java.lang.reflect.Method.invokeNative(Native Method) 07-06 11:47:50.414 I/MonoDroid(13296): at java.lang.reflect.Method.invoke(Method.java:515) 07-06 11:47:50.414 I/MonoDroid(13296): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) 07-06 11:47:50.414 I/MonoDroid(13296): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) 07-06 11:47:50.414 I/MonoDroid(13296): at dalvik.system.NativeStart.main(Native Method) 07-06 11:47:50.419 D/AndroidRuntime(13296): Shutting down VM 07-06 11:47:50.419 W/dalvikvm(13296): threadid=1: thread exiting with uncaught exception (group=0x41888c08)

like image 310
avb Avatar asked Dec 11 '22 22:12

avb


1 Answers

A simple Clean/Rebuild fixed this issue. Can't believe this wouldn't work a couple of days ago, when I tried that too...

like image 163
avb Avatar answered Feb 01 '23 04:02

avb