I am trying to write a unit test for Android, but I get a "NoClassdefFound"-error when executing following very simple code in one of my test methods:
public void testAAA(){
testAPI1 test = new testAPI1();
test.makeApiCall1();
}
The class testAPI1 looks like this:
public class testAPI1 implements SomeInterface{
public void makeApiCall1(){
//do something
}
}
SomeInterface is, well, just some interface. When I remove "SomeInterface", however, everything works fine.
The manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mamlambo.article.simplecalc.test" android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon"
android:label="@string/app_name">
<uses-library android:name="android.test.runner" />
</application>
<uses-sdk android:minSdkVersion="7" />
<instrumentation android:targetPackage="com.mamlambo.article.simplecalc"
android:name="android.test.InstrumentationTestRunner"
android:label="Simple Calc Test"/>
</manifest>
What exactly is the problem?
The issue was that the Interface I implemented was not found. The interface was in another project I referenced, which wasn't properly referenced apparently. What I did is export that project into a jar-file (without the AndroidManifest!), then imported it in my Test-Project, and everything worked fine from then on.