Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Unit Testing - Resolution & Verification Problems

I just switched the way my Android project is being built and non of my unit tests work any more...I get errors like

WARN/dalvikvm(575): VFY: unable to resolve static field X in .....
WARN/dalvikvm(575): VFY: unable to find class referenced in signature

These errors only come from my Unit Tests, where classes defined in it can't even see other classes defined in the unit test.

Before each project had its own directory with copies of the 3rd party jar files. I've read around that Dex does weird things with references but haven't been able to figure out how to fix this problem. Is there a better way to do this? I would love to see an example of a large Android workspace where there are multiple projects, jar references, etc...

Is it possible to fix this with an Order/Export tweak ?

The project is structured like this:

  • Eclipse Workspace (PROJECT_HOME classpath variable)
  • lib
    • 3rd-party jars
    • android.jar
  • Java Project A
    • Looks in PROJECT_HOME
  • Java Project B
    • Looks in PROJECT_HOME
    • Depends on project A
  • Android Project
    • Depends on A & B
    • Looks in PROJECT_HOME
  • Android Test Project
    • Depends on A , B, Android Project
    • Looks in PROJECT_HOME
like image 927
Bill Avatar asked Nov 14 '22 12:11

Bill


1 Answers

Do not include the 3rd party jar in the test project. Simply export it in the testee project: project properties->java build path->order and export. Once this is done, you'll be able to clean and it should work fine.

like image 172
Thomas Dignan Avatar answered Dec 30 '22 16:12

Thomas Dignan