有一個名爲TestAndroid的android項目。我能夠在我的Android設備上運行它沒有問題。不過,我希望能夠使用其他項目的代碼。所以我去我的構建路徑並添加項目測試。測試是一個使用java6的標準java項目。 Test項目有一個類Test,它只是一個空類。Android項目無法在eclipse中引用其他項目
雖然我在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安裝,因爲我有一個項目是我不得不引用其他項目和它的工作。我寧願現在修復它,完全重新安裝日食和我所有的插件。如果有人知道什麼是錯的,可以幫助我,我將不勝感激。謝謝!!
請參閱本文檔 - http://developer.android.com/guide/developing/projects/projects-eclipse.html – adatapost
@AVD我沒有試圖引用另一個android項目,而只是一個標準的java項目。 – Stratus
可能的重複[Android項目引用「正常」的Java項目在eclipse中自sdk工具更新17以來](http://stackoverflow.com/questions/9889572/android-project-referencing-normal-java-project-in-eclipse- since-sdk-tools-upd) –