我在安卓上遇到了一个奇怪的ClassCastException问题。一个类无法被转换为相同的类:
java.lang.RuntimeException: Unable to start activity ComponentInfo: java.lang.ClassCastException: com.example.model.BadeWrapper cannot be cast to com.example.model.BadgeWrapper
java.lang.ClassCastException: com.example.events.widgets.TouchyWebView cannot be cast to com.example.events.widgets.TouchyWebView
java.lang.ClassCastException: com.example.friends.widgets.FriendsTabView cannot be cast to com.example.friends.widgets.FriendsTabView
当我找到有错误的代码行时,它只是通过ID查找视图或使用参数创建片段,例如:
FriendsTabView friendsTabView;
friendsTabView = (FriendsTabView) view.findViewById(R.id.friends_bottom_tab_panel);
根据我的BugSense,这个问题只在三星Galaxy S5上发生,使用的是Android 5.0.0系统(三星SM-G900F)。我在其他设备上从未遇到过这个问题:Motorola Moto G第一代(Android 5.0.1)、三星Galaxy S3 Mini(Android 4.1.2)、LG G2 Mini(Android 4.4.2)和Sony Xperia L(Android 4.1.2)。有人遇到过这个问题吗?有什么方法可以解决吗?