views:

3926

answers:

7

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 (http://code.google.com/p/gdata-java-client/). 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.

+3  A: 

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?

TofuBeer
I don't know , I am doing it in Eclipse...
Isaac Waller
Would be awsome with some more info on the "dx" tool.
Daniel T. Magnusson
not much info... but: http://developer.android.com/guide/developing/tools/othertools.html#dx
TofuBeer
+2  A: 

Look at LogCat and see what's causing the verifyerror. It's probably some method in a java.lang class that is not supported on the android SDK level you are using (for instance, String.isEmpty()).

Alex
This should be marked as real answer. At least what it was exactly in my case since I was getting sporadic errors from my users and I tracked it down to View.getTag(int) call that is not supported in v. 3 of API
DroidIn.net
A: 

I get the VerfiyError as well... can't find a real reason. It helps to wrap the new lines of code into a method (Eclipse, 'Extract Method...'). So in my case the reason is not an unsupported method.

asdf wer
A: 

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:

<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
Macarse
A: 

I Have the Same Problem. I have made an Android app, and compiled it with Android 1.6 sdk. It works great on my G1 with Android 1.6 But with the HTC Hero with Android 1.5 I get java.lang.VerifyError

I guess thats the problem !

Frank Bouwens
+1  A: 

From android-developers:

The output from "adb logcat" indicates the class that could not be found as well as the class that has the bad reference. The location is identified down to the specific Dalvik instruction. The trick is to look in the logs above the exception.

ADB
Looking above the exception helped me, too, to identify the method that was causing the error.For me, it was the expression Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR which is kinda obvious, in the end, if you try that on Cupcake...
Manuel
A: 

I have same problem. Any one solved the problem ? pls share here.

piyushnp