Android java.lang.VerifyError?

2019-01-01 08:59发布

In my Android app, I always get VerifyErrors! And I cannot figure out why. Whenever I include a external JAR, I always get VerifyErrors when I try to launch my app (except for once, when I included Apache Log4j.)

I usually get around this by taking the source of the library and adding it to my project, but I am trying to put the GData client library.

I can get this in source, but it's dependencies (mail.jar, activation.jar, servlet-api.jar) I cannot, so I get verify errors. I would like to get to the root of this problem once and for all. I looked on the internet, but they all seem to talk about incomplete class files? which I do not know of.

30条回答
谁念西风独自凉
2楼-- · 2019-01-01 09:30

In Eclipse 4.x, if you encounter this problem, try below:

  1. migrate all included 3th-party jars into the User-Libaray
  2. move up the user lib before the android lib and check it in the Order and Export tab
  3. clean and rebuild to run
查看更多
回忆,回不去的记忆
3楼-- · 2019-01-01 09:30

I had very similar problem. I had added Apache POI jars and problem appeared when I updated to android SDK 22.3.

I had Android Private Libraries checked so this was not the common problem with android SDK. I unchecked all Apache POI jars and added one by one. I found that poi-3.9-20121203.jar should be before poi-ooxml-3.9-20121203.jar. Otherwise it will not work.

查看更多
无与为乐者.
4楼-- · 2019-01-01 09:30

If you have tests, try commenting out this line from your build.grade file:

testCoverageEnabled = true

For me this caused VerifyError exceptions on classes which use Java 1.7 features, particularly string switch statements.

查看更多
梦寄多情
5楼-- · 2019-01-01 09:31

I have coded Android API methods/class that are in SDK 2.1, and was trying to run it on Android 1.6 emulator. So i got that error.

SOLUTION: Changed it to correct emulator version.

THIS WORKED FOR ME.. Thanks.

查看更多
看风景的人
6楼-- · 2019-01-01 09:32

For me it was in correlation between compileSdkVersion and buildToolsVersion. I had:

compileSdkVersion 21
buildToolsVersion '19.1.0'

I changed it to:

compileSdkVersion 21
buildToolsVersion '21.1.2'
查看更多
骚的不知所云
7楼-- · 2019-01-01 09:33

If you're using Retrolambda you might have added a static method to an interface (which is only allowed in Java 8).

查看更多
登录 后发表回答