几天前,我们开始收到用户使用我们的应用程序的一些崩溃报告,但这种情况非常奇怪。它只发生在三星G900f(S5)上,我无法重现它并决定在这里发布一个问题。
stacktrace显示了这个:
Caused by java.lang.ClassCastException: android.support.design.widget.CollapsingToolbarLayout cannot be cast to android.support.design.widget.CollapsingToolbarLayout
at com.packageName.profile.ProfileFragment.onViewCreated(SourceFile:423)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1086)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1248)
at android.support.v4.app.BackStackRecord.run(SourceFile:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(SourceFile:1613)
at android.support.v4.app.FragmentController.execPendingActions(SourceFile:330)
at android.support.v4.app.FragmentActivity.onStart(SourceFile:547)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1234)
at android.app.Activity.performStart(Activity.java:6258)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5834)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
它是一个Fragment
,包含CollapsingToolbarLayout
初始化并使用所有正确的,但不确定为什么会发生这种情况。
我们从同一设备获得了一些具有不同类的其他ClassCastExceptions
。例如:
Caused by java.lang.ClassCastException:
com.packageName.model.VideoMeta cannot be cast to
com.packageName.model.VideoMeta
其中VideoMeta
是一个实现Parcelable
的类,此异常发生在实现Video
的类Parcelable
中:
private Video(Parcel in) {
id = in.readLong();
postId = in.readString();
url = in.readString();
thumb = in.readString();
meta = (VideoMeta) in.readValue(VideoMeta.class.getClassLoader());
}
但那不是结束......
Caused by java.lang.ClassCastException:
android.support.design.widget.AppBarLayout$LayoutParams cannot be cast to
android.support.design.widget.AppBarLayout$LayoutParams
我不知道是什么原因造成了这种例外,以及为什么会发生这种情况,这就是为什么要在这里发布的原因。
提前感谢任何帮助或建议!