A 有一个名为 TestAndroid 的 android 项目。我可以在我的安卓设备上运行它。但是我希望能够使用来自另一个项目的代码。所以我去我的构建路径并添加项目测试。测试是使用 java6 的标准 java 项目。Test 项目有一个类Test,它只是一个空类。
不过,这就是它搞砸的地方,当我在 TestAndroid 中创建一个 Test 实例时,我得到一个运行时错误。这是我从 logcat 得到的错误。
05-27 21:47:49.976: E/dalvikvm(27493): Could not find class 'com.tests.eclipseisbroken.Test', referenced from method com.tests.eclipseisbroken.TestAndrodiActivity.onCreate
05-27 21:47:49.986: W/dalvikvm(27493): VFY: unable to resolve new-instance 11 (Lcom/tests/eclipseisbroken/Test;) in Lcom/tests/eclipseisbroken/TestAndrodiActivity;
05-27 21:47:49.986: D/dalvikvm(27493): VFY: replacing opcode 0x22 at 0x0008
05-27 21:47:49.986: D/dalvikvm(27493): VFY: dead code 0x000a-000d in Lcom/tests/eclipseisbroken/TestAndrodiActivity;.onCreate (Landroid/os/Bundle;)V
05-27 21:47:50.026: D/AndroidRuntime(27493): Shutting down VM
05-27 21:47:50.046: W/dalvikvm(27493): threadid=1: thread exiting with uncaught exception (group=0x40028a00)
05-27 21:47:50.056: E/AndroidRuntime(27493): FATAL EXCEPTION: main
05-27 21:47:50.056: E/AndroidRuntime(27493): java.lang.NoClassDefFoundError: com.tests.eclipseisbroken.Test
05-27 21:47:50.056: E/AndroidRuntime(27493): at com.tests.eclipseisbroken.TestAndrodiActivity.onCreate(TestAndrodiActivity.java:16)
05-27 21:47:50.056: E/AndroidRuntime(27493): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1065)
05-27 21:47:50.056: E/AndroidRuntime(27493): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
05-27 21:47:50.056: E/AndroidRuntime(27493): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
05-27 21:47:50.056: E/AndroidRuntime(27493): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
05-27 21:47:50.056: E/AndroidRuntime(27493): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
05-27 21:47:50.056: E/AndroidRuntime(27493): at android.os.Handler.dispatchMessage(Handler.java:99)
05-27 21:47:50.056: E/AndroidRuntime(27493): at android.os.Looper.loop(Looper.java:143)
05-27 21:47:50.056: E/AndroidRuntime(27493): at android.app.ActivityThread.main(ActivityThread.java:4914)
05-27 21:47:50.056: E/AndroidRuntime(27493): at java.lang.reflect.Method.invokeNative(Native Method)
05-27 21:47:50.056: E/AndroidRuntime(27493): at java.lang.reflect.Method.invoke(Method.java:521)
05-27 21:47:50.056: E/AndroidRuntime(27493): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
05-27 21:47:50.056: E/AndroidRuntime(27493): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-27 21:47:50.056: E/AndroidRuntime(27493): at dalvik.system.NativeStart.main(Native Method)
我认为我的 Eclipse 安装一定有问题,因为我有一个项目,我必须引用另一个项目并且它有效。我宁愿现在修复它,完全重新安装 eclipse 和我所有的插件。如果有人知道出了什么问题并可以帮助我,我将不胜感激。谢谢!!