GAMA GAMA - 5 months ago 40
Android Question

VerifyError - Verifier rejected class

I'm developing for 2.2 (

) and suddenly I'm getting this error:

arbitrarily rejecting large method (regs=75 count=28584)
rejected Lcom/Demo/Loyalty/SelectType;.onClick (Landroid/view/View;)V
Verifier rejected class Lcom/Demo/Loyalty/SelectType;
Class init failed in newInstance call (Lcom/Demo/Loyalty/SelectType;)

java.lang.VerifyError: com.Demo.Loyalty.SelectType
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(
at dalvik.system.NativeStart.main(Native Method)

It was working fine until now.

Note :
class has around 16000 lines of code but that is not that large I guess.

I search a lot on net and from answers, I did following:

  • Clean the project

  • Reset the ADB

  • Restart emulator/device/eclipse

  • Checked that third party library field is checked in build path

But I'm still getting that error.

Any help appreciated.

Answer Source

The steps you've described probably won't help.

The thing is, it's not a Dalvik issue. Similar verifier is employed in the Oracle Java VM for example. Simple answer: your method is too complex. The error you see is mainly caused by too many:

  • parameters
  • local variables
  • exception handlers
  • code instructions

More precisely, the issue has been described in this thread:!topic/android-developers/4qNoIdBHYFc

To quote:

The value of (number of registers * number of instruction words) is larger than 2^21. (...) it's intended to prevent the verifier from bloating up an app's native heap.

You can also see similar report here: with pointers on how to resolve the issue:

Yep, the Dalvik compiler attempts to assign a "register" to every local variable in the method. It should be able to handle that many, but apparently can't. By making them instance variables you remove the compiler's need/desire to "manage" them (and also make the method a fair amount smaller).

So to solve it, you should generally break the large method (probably onClick()?) into smaller pieces. Also, converting local variables to class fields seemed to help some people with the same issue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download