Snackbar问题(仅在调试模式下)

时间:2015-07-06 10:06:31

标签: xamarin.android classcastexception androiddesignsupport android-snackbar snackbar

我在android支持设计库中遇到了Snackbar的问题。 奇怪的是,它只发生在我在调试模式下运行我的应用程序时,在发布模式下它才能完美运行。

有人对这个问题有所了解吗?它似乎是支持库中的一个错误。

代码

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

异常

07-06 11:47:50.414 I / MonoDroid(13296):Java.Lang.ClassCastException:类型' Java.Lang.ClassCastException'的异常。被扔了。 07-06 11:47:50.414 I / MonoDroid(13296):在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 07-06 11:47:50.414 I / MonoDroid(13296):在C:\ Development \ Apps \ FieldService-Tablet \ OverAllF07中的OverAllField.XamarinAndroid.Fragments.Planning.PlanningFragment.FloatingActionButton_Click(object,System.EventArgs)[0x00001] -06 11:47:50.414 I / MonoDroid(13296):在/ Users / builder / data / lanes / 1502/24855232中的Android.Runtime.JNIEnv.CallStaticObjectMethod(intptr,intptr,Android.Runtime.JValue *)[0x00064] /source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1301 07-06 11:47:50.414 I / MonoDroid(13296):在Android.Support.Design.Widget.Snackbar.Make(Android.Views.View,Java.Lang.ICharSequence,int) 07-06 11:47:50.414 I / MonoDroid(13296):在Android.Support.Design.Widget.Snackbar.Make(Android.Views.View,string,int) 07-06 11:47:50.414 I / MonoDroid(13296):位于c:\ Development \ Apps \ FieldService-Tablet \ OverAllField中的OverAllField.XamarinAndroid.Fragments.Planning.PlanningFragment.FloatingActionButton_Click(object,System.EventArgs)[0x00001] .XamarinAndroid \ OverAllField.Android \片段\规划\ PlanningFragment.cs:74 07-06 11:47:50.414 I / MonoDroid(13296):在/ Users / builder / data / lanes / 1502/24855232 / source中的Android.Views.View / IOnClickListenerImplementor.OnClick(Android.Views.View)[0x0000d] /monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:1923 07-06 11:47:50.414 I / MonoDroid(13296):在/ Users / builder / data / lanes / 1502/24855232 / source中的Android.Views.View / IOnClickListenerInvoker.n_OnClick_Landroid_view_View_(intptr,intptr,intptr)[0x00011] /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):---托管异常堆栈跟踪结束--- 07-06 11:47:50.414 I / MonoDroid(13296):java.lang.ClassCastException:android.widget.LinearLayout无法强制转换为android.support.design.widget.Snackbar $ SnackbarLayout 07-06 11:47:50.414 I / MonoDroid(13296):在android.support.design.widget.Snackbar。(Snackbar.java:119) 07-06 11:47:50.414 I / MonoDroid(13296):在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):在mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:29) 07-06 11:47:50.414 I / MonoDroid(13296):在android.view.View.performClick(View.java:4754) 07-06 11:47:50.414 I / MonoDroid(13296):在android.view.View $ PerformClick.run(View.java:19605) 07-06 11:47:50.414 I / MonoDroid(13296):在android.os.Handler.handleCallback(Handler.java:733) 07-06 11:47:50.414 I / MonoDroid(13296):在android.os.Handler.dispatchMessage(Handler.java:95) 07-06 11:47:50.414 I / MonoDroid(13296):在android.os.Looper.loop(Looper.java:146) 07-06 11:47:50.414 I / MonoDroid(13296):在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):关闭VM 07-06 11:47:50.419 W / dalvikvm(13296):threadid = 1:线程退出未捕获异常(组= 0x41888c08)

1 个答案:

答案 0 :(得分:12)

简单的清理/重建修复了此问题。我不相信这在几天前也不会起作用,当时我也试过了......