问题
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)
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!
回答1:
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.
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.
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.
来源:https://stackoverflow.com/questions/31122666/how-work-around-java-lang-verifyerror-in-android