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.
For posterity, I just got this error because I was using
Arrays.copyOf()
which is not a method supported by Java 1.5 which corresponds to Android Level 4. Because I was running including libraries developed under 1.6 they compiled fine. I only saw the problems when I moved the class in question over to my Android project -- then the error was highlighted.On that line I was trying to do a
new DaoConfigArray
and that class had the following line:What made it even more complicated is that line 71 was pointing to a
ThreadLocal
initialization which I thought was the reason for the problem initially.For me, the issue ended up actually being that I was using multi-catch clause somewhere in the class which is a Java 7 feature (and API 19+). So it would crash with
VerifyError
on all pre-19 devices.Android uses a different class file format. Are you running the 3rd party JAR files through the "dx" tool that ships with the Android SDK?
I downgrade gradle version from 2.0.0-alpha2 to 1.5.0 that solved this problem.
I had the same issue. I was building with 2.1 r1 and updated to 2.1 r3 with the new adt 17. I had verify errors on javamail's mail.jar and it was driving me crazy. Here is how i solved the issue:
i tried a rebuild and it failed. I removed the libs/ directory as a source folder and removed refs to the 3 jar files in the build path. Then i added the libs/ folder again, and added each jar in the libs/ folder to the build path. Now it works as expected. This is a weird workaround but it worked for me.
It happened to me right now. The error was caused because I was using methods from a newer SDK that my device had.
Android 1.5 device installed an apk using this: