Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError when running Instrumentation test with ant

(This is an Android SDK tools v17 problem. Expect a fix in v18)

I have a test target project A, and a tester project B.

Project A has FlurryAgent.jar in its libs folder.

Project B has robotium-solo-3.1.jar in its libs folder

When I compile and run them,

cd A
android update project -p .
cd ..
cd B
android update test-project -p . -m ../A
ant all clean debug
ant uninstall
ant installt
ant test

ant test fails to execute tests:

test:
     [echo] Running tests ...
     [exec]
     [exec] com.example.r17.test.TestOne:
     [exec] INSTRUMENTATION_RESULT: shortMsg=java.lang.NoClassDefFoundError
     [exec] INSTRUMENTATION_RESULT: longMsg=java.lang.NoClassDefFoundError: com.flurry.android.FlurryAgent
     [exec] INSTRUMENTATION_CODE: 0

I've read some posts/questions that solve this problem in Eclipse. But I don't think I can run Eclipse on headless Jenkins slave.

like image 638
Qi Fan Avatar asked Mar 23 '12 22:03

Qi Fan


1 Answers

Since this post was the first in search engine results when I entered "java.lang.NoClassDefFoundError: com.flurry.android.FlurryAgent" and my issue was not related to Ant at all, I thought I'd add some info for people who might be scratching their heads after re-installing the ADT.

Basically, in Eclipse when you add an external library in the Java Build Path dialog, don't forget to also switch to the Order and Export tab and tick that library's name in the list. This is needed so that the library is found at run-time, not only at compile time :)

like image 119
Levon Avatar answered Oct 07 '22 00:10

Levon