VerifyError in android test-project build tools v17
Asked Answered
P

5

12

Since installing v17 of the android build tools I am getting a VerifyError in my test project.

A short description of my project structure:

All jar files exist in my main projects libs folder

The test-project is a project that resides inside my main project

All Instrumentation tests exist in the same package as my activities.

I have one jar that is only needed for the test projects in my libs folder in the test project

Has anyone seen this? Its happening on all my projects since updating. Running the test produces an InstrumentationException: java.lang.VerifyError

Puleo answered 22/3, 2012 at 18:57 Comment(13)
try cleaning your entire project and then rebuilding?Oligopoly
I am doing clean builds. Sorry for not clarifying that in the post.Puleo
UPDATE So it looks like we are able to get around this but so far the process of doing so requires the following steps: 1. ant clean debug on the main project 2. adb install main project 3. ant clean debug on the test project 4. adb install test project 5. ant test 6. ant clean debug on the main project again 7. adb install main project 8. ant test on test project 9. ... 10. ProfitPuleo
And after you do this once, you still need to continue to get broken builds and have to continue cleaning like this?Oligopoly
If I rebuild the test project no. If I modify the main project I will get the VerifyError and have to redo these steps.Puleo
do the API levels betweeen your test and main projects correspond. This usually happens because of library code with older versions of the platform.Oligopoly
@KristopherMicinski The target set in project.properties for both projects is android-10 and the minSdkVersion is set to 8 in the main projectPuleo
what do you mean by "The test-project is a project that resides inside my main project". is it just the folder set up?I'm really not sure why all your cleaning/building steps would helpHecht
@Xav my folder hierarchy is main-project/test/... for the test project. Im really not sure either about the building and cleaning but it works and makes absolutely no sense to mePuleo
@Xav I think I figured out whats going on... The first 2 steps above are not necessary. Whats happening is that ant clean debug on the test project is generating a debug binary for the main project but it is not the same as the binary generated by ant clean debug run on the main projects build.xmlPuleo
how does your test project reference your main project?Hecht
tested.project.dir=../ in the ant.properties filePuleo
I was able to reproduce. I did a fix today that seemed to have many effect. can you go to tools.android.com/download and get the anttasks.jar from there and put it in SDK/tools/lib/ (where there should already be one) and test with it. thanks.Hecht
E
6

[email protected] made a temporary fix for an issue I reported: http://code.google.com/p/android/issues/detail?id=27608.

You can try to see if the new anttasks.jar file can fix your problem.

It fixed mine. NoClassDefFoundError when running Instrumentation test with ant

Edelstein answered 26/3, 2012 at 17:47 Comment(1)
I can confirm that the replacement anttasks.jar fixed this issue with ant for me to. To help future readers find this answer: an additional symptom I was seeing with this bug is that the ant "debug" task in the test subproject would recreate the main applications APK and corrupt it - mine would go from being 800KB down to 8KB in size, I guess this was leaving out all my dependent jar classes.Piggott
S
5

In my case, I have a test project using the library of "robotium". I'd had the same problem, and soleved by following steps,

  1. "Properties > Java Build Path > Libraries", delete "Android Dependencies" in my test project.
  2. "Properties > Java Build Path > Libraries", delete two robotium jar and click "Add JARs" to re-import robotium jar in my test project.
  3. "Properties > Java Build Path > Order and Export", check two checkbok of robotium jar (and othera you want exported.)
  4. Clean my test project.

I think you also solve the problem, Good Luck!

more information

  • How to fix the “NoClassDefFoundError” with ADT 17
  • Dealing with dependencies in Android projects
  • Semantics answered 25/3, 2012 at 4:38 Comment(2)
    Deleting "Android Dependencies" can have side effects, for example won't the custom annotations in the sdk be loaded anymore.Pulpboard
    Exactly! Now, you can test by following configurations. test project 1. Not Export: Android x.x.x 2. Not Export: robotium 3. Not Export: robotium 4. Not Export: Android Dpendencies product 1. Not Export: Android x.x.x 2. Not Export: android-support-v4.jar 3. Not Export: Android DpendenciesSemantics
    C
    1

    in my case, first, add robotium-solo-2.5 in properties->build path->Libraries,and then move robotium-solo-2.5.jar to the top in properties->build path->Order and export, finally i solve this funny problem easily...

    Chaechaeronea answered 18/7, 2012 at 4:50 Comment(0)
    F
    0

    “Properties > Java Build Path > Order and Export”, and check all the references you want exported.

    Fuller answered 25/3, 2012 at 2:58 Comment(0)
    P
    0

    The way Android deals with dependencies has recently changed. If you are using eclipse, then just remove your jar imports and place them in a "libs"-folder in the project root, and everything will be imported automatically.

    Pulpboard answered 26/3, 2012 at 12:44 Comment(0)

    © 2022 - 2024 — McMap. All rights reserved.