我有 2 个项目:dummy 和 dummy-android。dummy-android 使用来自 dummy 的 Game 类。我在 dummy-android 的构建路径中包含了 dummy 但在模拟器上运行时。它生成:
E/AndroidRuntime( 691): java.lang.NoClassDefFoundError: com.dummy.Game
E/AndroidRuntime( 691): at com.dummy.activity.AndroidGame.onCreate(AndroidGame.java:13)
E/AndroidRuntime( 691): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 691): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 691): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 691): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 691): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 691): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 691): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 691): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 691): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 691): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 691): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 691): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 691): at dalvik.system.NativeStart.main(Native Method)
我试图从 dummy-android 的构建路径中删除 dummy,清理,重新包含它,清理但它仍然不起作用。
我的项目没有显示任何编译错误!这是 Eclipse 的一个错误!如何解决?谢谢你。
更新:尝试重新启动Eclipse,多次清理两个项目,重新运行,没有任何变化。
更新: @Martin Brakash。我取消选中两个项目中的项目特定设置。它生成一个新异常:
05-15 04:48:14.575: E/AndroidRuntime(971): FATAL EXCEPTION: main
05-15 04:48:14.575: E/AndroidRuntime(971): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.dummy.activity/com.dummy.activity.AndroidGame}: java.lang.ClassNotFoundException: com.dummy.activity.AndroidGame in loader dalvik.system.PathClassLoader[/data/app/com.dummy.activity-1.apk]
05-15 04:48:14.575: E/AndroidRuntime(971): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
05-15 04:48:14.575: E/AndroidRuntime(971): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-15 04:48:14.575: E/AndroidRuntime(971): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-15 04:48:14.575: E/AndroidRuntime(971): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-15 04:48:14.575: E/AndroidRuntime(971): at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 04:48:14.575: E/AndroidRuntime(971): at android.os.Looper.loop(Looper.java:123)
05-15 04:48:14.575: E/AndroidRuntime(971): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-15 04:48:14.575: E/AndroidRuntime(971): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 04:48:14.575: E/AndroidRuntime(971): at java.lang.reflect.Method.invoke(Method.java:521)
05-15 04:48:14.575: E/AndroidRuntime(971): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-15 04:48:14.575: E/AndroidRuntime(971): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-15 04:48:14.575: E/AndroidRuntime(971): at dalvik.system.NativeStart.main(Native Method)
05-15 04:48:14.575: E/AndroidRuntime(971): Caused by: java.lang.ClassNotFoundException: com.dummy.activity.AndroidGame in loader dalvik.system.PathClassLoader[/data/app/com.dummy.activity-1.apk]
05-15 04:48:14.575: E/AndroidRuntime(971): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-15 04:48:14.575: E/AndroidRuntime(971): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-15 04:48:14.575: E/AndroidRuntime(971): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-15 04:48:14.575: E/AndroidRuntime(971): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-15 04:48:14.575: E/AndroidRuntime(971): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-15 04:48:14.575: E/AndroidRuntime(971): ... 11 more