我试图让一个游戏项目完全独立于平台,所以我把它分成三个项目,从低级到顶级 android 特定级别:引擎、游戏、android 游戏。
错误中涉及的类/接口是:
(低级)引擎项目定义了这个接口:
com.myteam.engine.IGame
(中级)平台独立游戏项目定义了这些类:
com.myteam.myproject.Game com.myteam.myproject.MyProject (derived from com.myteam.myproject.Game)
(顶级)android项目实现活动等:
com.myteam.myproject.android.MyAndroidActivity (using com.myteam.myproject.MyProject)
所有的编译都很好,并且在 Windows 下完美运行(在第 3 级的另一个 Windows 项目使用前两个)。
但是当使用 ADT 运行时,它会在 Activity 启动时在运行时失败。Android 应用程序基本上只显示一个带有“NoClassDefFoundError com.myteam.myproject.MyProject”异常的调用堆栈。
该异常似乎是由其超类(或超类的接口)在加载/解析时引起的,因为 LogCat 输出显示:
12-20 19:51:51.897: D/ddm-heap(218): Got feature list request
12-20 19:51:52.207: I/dalvikvm(218): Failed resolving Lcom/myteam/myproject/Game; interface 18 'Lcom/myteam/engine/IGame;'
12-20 19:51:52.217: W/dalvikvm(218): Link of class 'Lcom/myteam/myproject/Game;' failed
12-20 19:51:52.227: W/dalvikvm(218): Unable to resolve superclass of Lcom/myteam/myproject/MyProject; (52)
12-20 19:51:52.227: W/dalvikvm(218): Link of class 'Lcom/myteam/myproject/MyProject;' failed
12-20 19:51:52.227: E/dalvikvm(218): Could not find class 'com.myteam.myproject.MyProject', referenced from method com.myteam.myproject.android.MyAndroidActivity.onCreate
12-20 19:51:52.227: W/dalvikvm(218): VFY: unable to resolve new-instance 54 (Lcom/myteam/myproject/MyProject;) in Lcom/myteam/myproject/android/Youcode_AndroidActivity;
12-20 19:51:52.227: D/dalvikvm(218): VFY: replacing opcode 0x22 at 0x0008
12-20 19:51:52.227: D/dalvikvm(218): Making a copy of Lcom/myteam/myproject/android/Youcode_AndroidActivity;.onCreate code (88 bytes)
我尝试在 Android 游戏项目的“构建路径/顺序和导出”Eclipse 项目设置下添加前两个项目,如其他帖子和论坛中所述,但这并没有改变任何事情。
我的预感是 Manifest 或 Project 设置需要另外提及用于 apk 打包或运行时的包/类依赖项。有任何想法吗?