VerifyError - Verifier rejected class

杀马特。学长 韩版系。学妹 提交于 2019-12-01 18:06:34

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: https://groups.google.com/forum/?fromgroups=#!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: http://www.mentby.com/Group/android-developers/verifyerror-arbitrarily-rejecting-large-method.html 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!