2

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?

user1028741
  • 2,745
  • 6
  • 34
  • 68
  • What are you doing at PuzzleActivity.java:55 ? And the reflective operation exception is comming from where? Android API, Java, custom? And here is a good question and answers at stackoverflow http://stackoverflow.com/questions/100107/reasons-of-getting-a-java-lang-verifyerror – Rene M. Jul 28 '14 at 09:55

1 Answers1

5

ReflectiveOperationException was added in API Level 19. Any device running something older than Android 4.4 will not have this class, and one source of a VerifyError is trying to use a class that does not exist.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491