Android Robotium NoClassDefFoundError

Micky picture Micky · Mar 26, 2012 · Viewed 11.9k times · Source

I was just trying to use Robotium in an Android JUnit Test, but the Testing always fails with an error:

java.lang.NoClassDefFoundError: com.jayway.android.robotium.solo.Solo

thrown at solo = new Solo(getInstrumentation(), getActivity()); in the setUp() method:

protected void setUp() throws Exception {
    super.setUp();
    solo = new Solo(getInstrumentation(), getActivity());
}

I read somewhere that this could be related to the Android SDK revision 17, but I cannot confirm this, as I first tried Robotium already with SDK 17.

The Robotium jar is properly added to the project build path.

Has anyone encountered similar problems?

Regards K.

Answer

Roberto Leinardi picture Roberto Leinardi · Mar 27, 2012

I had the same problem today. I solved by importing the jar into the libs directory of the test project and then adding it to the Build Path Libraries:

TestProject Properties -> Java Build Path -> Libreries -> Add JARs... -> TestProject/libs/robotium-solo-3.1.jar