私は現在単体テストを作成している Android アプリケーションを開発しました。2 番目のプロジェクト (プロジェクト名として ".test" という接尾辞が付いている) を作成し、元のプロジェクトをターゲットとして選択しました。
私の元のプロジェクトには、いくつかの外部 JAR ファイルが含まれています。
テスト プロジェクトのビルド パスでもこれらの JAR ファイルを参照しないと、テストからすべてのメソッドにアクセスできません。例として、次のエラーが発生します。
The type com.j256.ormlite.android.apptools.OrmLiteBaseService cannot be resolved. It is indirectly referenced from required .class files
ただし、テストは正しく機能します (これらのメソッドにアクセスしていない場合)。
ただし、必要な JAR ファイルをテスト プロジェクトのビルド パスに含めると、次のエラーが発生します。
05-16 15:59:03.732: INFO/TestRunner(1222): java.lang.NoClassDefFoundError: sw6.visualschedule.persistence.DatabaseHelper
05-16 15:59:03.732: INFO/TestRunner(1222): at sw6.visualschedule.test.ScheduleActivityTest.setUp(ScheduleActivityTest.java:22)
05-16 15:59:03.732: INFO/TestRunner(1222): at junit.framework.TestCase.runBare(TestCase.java:125)
05-16 15:59:03.732: INFO/TestRunner(1222): at junit.framework.TestResult$1.protect(TestResult.java:106)
05-16 15:59:03.732: INFO/TestRunner(1222): at junit.framework.TestResult.runProtected(TestResult.java:124)
05-16 15:59:03.732: INFO/TestRunner(1222): at junit.framework.TestResult.run(TestResult.java:109)
05-16 15:59:03.732: INFO/TestRunner(1222): at junit.framework.TestCase.run(TestCase.java:118)
05-16 15:59:03.732: INFO/TestRunner(1222): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
05-16 15:59:03.732: INFO/TestRunner(1222): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
05-16 15:59:03.732: INFO/TestRunner(1222): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:520)
05-16 15:59:03.732: INFO/TestRunner(1222): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
NoClassDefFoundError を解決するにはどうすればよいですか? プロジェクト内のクラスを参照していて、外部 JAR ファイルがビルド パスに含まれていない場合に機能するため、本当に混乱しています。
OSXでEclipseを使用していますが、それが影響している場合。