不能赶上java.lang.VerifyError [英] can't catch java.lang.VerifyError

查看:260
本文介绍了不能赶上java.lang.VerifyError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到这个错误:
未捕获的处理程序:螺纹主力退出,由于未捕获的异常java.lang.VerifyError

这只是发生在1.6。 Android的2.0及以上没有任何问题,但是这一切的重点。

我听不太清楚的错误/异常(的VerifyError),我知道它被调用isInitialStickyBroadcast(造成的)这是不是在SDK 4个可用,这就是为什么它包裹在SDK检查。我只需要这个广播接收器在2.0+工作和1.6不破,它在市场上的应用程序,需要脱离对接功能上2.0+用户,但显然不是1.6,但有网友还是对1.6的相当数量。

如何解决?

谢谢!

 私人广播接收器mUndockedReceiver =新的广播接收器()
{
      @覆盖
      公共无效的onReceive(上下文的背景下,意图意图)
      {
          // FROM ECLAIR FORWARD,前DONUT此空间没有得到执行
          如果(Build.VERSION.SDK_INT> = 5)
          {
              如果(!isInitialStickyBroadcast()){
                  INT dockState = intent.getExtras()调用getInt(android.intent.extra.DOCK_STATE,1);
                  如果(dockState == 0)
                  {
                      完();
                  }
              }
          }
      }
};


解决方案

Intent.EXTRA_DOCK_STATE 仅在API 5级以上的存在,所以只能在Android 2.0运行设备(或以​​上)。

即使虽然你包裹在API层面检查的号召,code会失败,当你在Android 1.6运行时运行,因此的VerifyError

该解决方案将与它的恒定值,以取代调用 Intent.EXTRA_DOCK_STATE android.intent.extra.DOCK_STATE


作为一般规则,它是由API级过滤器复选框浏览API文档时,剔,它在你的情况设置为4个好主意。这样一来,任何类,方法或常量不能使用到Android 1.6将是灰色的。

I'm getting this error: "Uncaught handler: thread main exiting due to uncaught exception java.lang.VerifyError"

It's only happening on 1.6. Android 2.0 and up doesn't have any problems, but that's the main point of all.

I Can't catch the Error/Exception (VerifyError), and I know it's being caused by calling isInitialStickyBroadcast() which is not available in SDK 4, that's why it's wrapped in the SDK check. I just need this BroadcastReceiver to work on 2.0+ and not break in 1.6, it's an app in the market, the UNDOCK feature is needed for users on 2.0+ but obviously not in 1.6 but there is a fairly amount of users still on 1.6.

How to fix?

Thanks!

private BroadcastReceiver mUndockedReceiver = new BroadcastReceiver()
{
      @Override
      public void onReceive(Context context, Intent intent) 
      {
          //FROM ECLAIR FORWARD, BEFORE DONUT THIS INTENT WAS NOT IMPLEMENTED
          if (Build.VERSION.SDK_INT >= 5)
          {
              if (!isInitialStickyBroadcast()) {
                  int dockState = intent.getExtras().getInt("android.intent.extra.DOCK_STATE", 1);
                  if (dockState == 0)
                  {
                      finish();
                  }
              }
          }           
      }
};  

解决方案

Intent.EXTRA_DOCK_STATE only exists in API level 5 and above, so will only work on Android 2.0 devices (or above).

Even although you're wrapping the call in an API level check, the code will fail when you run it on an Android 1.6 runtime, hence the VerifyError.

The solution would be to replace the call to Intent.EXTRA_DOCK_STATE with its constant value: android.intent.extra.DOCK_STATE.


As a general rule, it's a good idea to tick the "Filter by API level" checkbox when browsing the API documentation, and set it to 4 in your case. That way, any classes, methods or constants not available to Android 1.6 will be greyed-out.

这篇关于不能赶上java.lang.VerifyError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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