简体   繁体   中英

VerifyError - only on some android devices

I build an android app. For some reason I get VerifyError on some devices (for instance Samsung Galaxy), and not on other devices (for example on Nexus 5).

The exception is thrown over this line:

AdManager.getInstance().preInit();

The exeption stack is:

java.lang.VerifyError: org/example/crossword/Ads/AdManager
at org.example.crossword.PuzzleActivity.onCreate(PuzzleActivity.java:55)
at android.app.Activity.performCreate(Activity.java:5255)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2213)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
at android.app.ActivityThread.access$700(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5306)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)

After trying to identify what causes the problem, I noticed that I have the line:

catch (ReflectiveOperationException e) { ...

When I remove this line, and use general Exception instead, the VerifyError doesn't occur.

So, I'm wondering why does the ReflectiveOperationException causes this error on some devices?

在API级别19中添加了ReflectiveOperationException 。任何运行Android 4.4之前版本的设备都不会具有此类, VerifyError一个来源正在尝试使用一个不存在的类。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM