Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
526 views
in Technique[技术] by (71.8m points)

android - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...