Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError while running JUnit test in Netbeans

I am building an Android hello world application in Netbeans. It's building properly and I am able to run in the emulator also.

But when creating and running the Junit test I get a java.lang.NoClassDefFoundError.

How can I fix this problem?

like image 411
Chandru K Avatar asked May 26 '10 12:05

Chandru K


2 Answers

Check the manifest of your test project, for example HelloWorldTest/AndroidManifest.xml. The android:targetPackage attribute of the instrumentation markup should target the package in your application, for example, com.example.helloworld. Not the test package of your test project (eg. com.example.helloworld.test).

like image 146
philippe_b Avatar answered Oct 12 '22 01:10

philippe_b


Simply AndroidManifest.xml -> manifest -> package of main application should match AndroidManifest.xml -> manifest -> instrumentation -> android:targetPackage of the test application.

like image 38
Eng.Fouad Avatar answered Oct 11 '22 23:10

Eng.Fouad