类转换异常在Android上同一类 [英] Class cast exception to same class on Android

查看:424
本文介绍了类转换异常在Android上同一类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,ClassCastException异常在Android上。一类不能被强制转换为同一类:

I'm having a strange problem with ClassCastException on Android. One class cannot be casted to the same class:

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或带参数的创建片段,例如:

When I find the line with error, all it does is finding view by id or creating fragment with arguments e.g.:

FriendsTabView friendsTabView;
friendsTabView = (FriendsTabView) view.findViewById(R.id.friends_bottom_tab_panel);

由于我BugSense告诉,只在三星Galaxy S5采用Android 5.0.0(三星SM-G900F)发生此问题。我从来没有遇到过这个问题,我的其他设备:

As my BugSense tells, this problem occurs only on Samsung Galaxy S5 with android 5.0.0 (samsung SM-G900F). I have never met this problem on my other devices:

  • 摩托罗拉摩托摹第一代(安卓5.0.1)
  • 在三星Galaxy S3迷你(安卓4.1.2)
  • LG G2迷你(安卓4.4.2)
  • 在索尼Xperia L(安卓4.1.2)

任何人都遇到了这个问题之前?有什么办法解决?

Anyone met this problem before? Is there any way to fix it?

推荐答案

好吧,我哪里出了问题。看起来三星在Android 5.0可能仍然使用旧的实现multidex的(在Android中大号preVIEW使用),因此,如果您的应用程序已超过64K的限制,它会在你使用(例如ExampleClass)对象演员。

Ok I where the problem is. Looks like Samsung on Android 5.0 probably still uses old implementation of multidex (used in Android L Preview), so if your app exceeds the 64k limit, it will crash in random places on your app where you use (ExampleClass) object cast.

在此问题的详细信息,可以发现<一href="http://developer.samsung.com/forum/thread/application-crushes-after-update-to-lollipop-on-samsung-galaxy-s5/202/278011?boardName=General&startId=zzzzz~">here和这里

More info on this problem can be found here and here.

我们也看到这个崩盘发生数千每天次。 Crashlytics报告崩溃为100%三星设备(99%SM G900F [Q]设备),和100%的Andr​​oid 5.x的似乎是三星+棒棒糖设备的另一multidex问题,如#3 a.jaskev报告。

We're also seeing this crash happen thousands of times per day. Crashlytics reports the crash as 100% Samsung devices (99% "SM G900F[Q]" device), and 100% Android 5.x. Seems to be another multidex issue on Samsung + Lollipop devices, as a.jaskev reports in #3.

看起来我们要等到三星解决此问题。现在,我们所能做的就是看我们的垃圾邮件的邮箱与错误报告:)

Looks like we have to wait until Samsung resolve this problem. Right now all we can do is watching our spam on mailbox with bug reports :)

这篇关于类转换异常在Android上同一类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆