喜試圖在Eclipse中運行我的單元測試時,我收到以下錯誤:java.lang.NoClassDefFoundError:安卓/測試/ AndroidTestCase
java.lang.NoClassDefFoundError: android/test/AndroidTestCase
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: android.test.AndroidTestCase
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 18 more
測試類
public class ResponseUtilTest extends AndroidTestCase {
private BubbleResponseUtil responseUtil;
private static final String TAG = ResponseUtilTest.class.getSimpleName();
@Override
protected void setUp() throws Exception {
super.setUp();
responseUtil = new ResponseUtil();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
public void testGetdata() {
}
public void testIsOkMessage() {
}
public void testIsRetryMessage() {
}
public void testIsMatchedCRC() {
}
}
感謝所有我我使用的是Android開發者網站上的Android SDK s Eclipse版本。
再次感謝
這絕對是重複 - 但我不確定哪一個。關於這個SO錯誤有幾十個問題 - 搜索它們。 –
在Netbeans中運行JUnit測試時[java.lang.NoClassDefFoundError可能重複](http://stackoverflow.com/questions/2912897/java-lang-noclassdeffounderror-while-running-junit-test-in-netbeans) –
不是其中一個實際上被標記爲正確的回答問題 – jonney