如何解决 Android 中的 java.lang.verifyerror [英] How work around java.lang.verifyerror in Android

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

问题描述

我有一个在所有 4.x 设备上都可以完美运行的应用程序,但现在我有一个报告说该应用程序无法在 samsung_gt (advance) android 2.3.6 上运行.这是跟踪:

I have an app which works perfect in all 4.x devices, but now I have a report of the app not working on a samsung_gt (advance) android 2.3.6. Here is the trace:

FATAL EXCEPTION: main
java.lang.VerifyError: com.bamobile.fdtks.activities.MainActivity
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1409)
at android.app.Instrumentation.newActivity(Instrumentation.java:1024)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
at android.app.ActivityThread.access$1500(ActivityThread.java:121)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3770)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(Native Method)

我有最新的支持 jar (v4) 并且已经修补了 gson 库,以防手机已经在使用它.问题似乎是支持库.有任何想法吗?非常感谢!

I have the latest support jar (v4) and have already patched the gson library in case the phone is already using it. The problem seems to be the the support lib. Any ideas? Thank you very much!

推荐答案

java.lang.VerifyError 的最常见原因是有一个类使用了 Android 版本上不可用的方法应用运行的位置.

The most common cause of java.lang.VerifyError is having a class that uses methods that are not available on the version of Android where the app is running.

根据您的堆栈跟踪,com.bamobile.fdtks.activities.MainActivity 似乎使用了一种在 Android 2.3.6 上不可用的方法,因此您的验证错误"重见天日.

Based on your stacktrace, it seems that com.bamobile.fdtks.activities.MainActivity is using a method that is not available on Android 2.3.6, hence the "verification error" that you're seeing.

要修复它,请将您的应用的 minSdkVersion910 (Android 2.3.6) 和查找错误/有关该版本 Android 不受支持的方法的警告.您还可以(临时)将 minSdkVersiontargetSdkVersion 更改为 9 以在您使用 Gingerbread 中找不到的方法时强制编译器失败设备.

To fix it, change the minSdkVersion and of your app to 9 or 10 (Android 2.3.6) and look for errors/warnings about unsupported methods for that version of Android. You can also change (temporarily) both minSdkVersion and targetSdkVersion to 9 to force the compiler to fail when you use methods that are not found in Gingerbread devices.

这篇关于如何解决 Android 中的 java.lang.verifyerror的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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