在Eclipse中/ ADT与项目相关性(无法分辨XY)的Android活动 [英] Android Activity under Eclipse/ADT with Project Dependencies (Failed resolving XY)
问题描述
我试图保持一个游戏项目相当平台无关的,所以我从低层次分割成三个项目顶部的Android特定级别这样的:发动机,游戏,安卓游戏
I tried to keep a game project quite platform independent so I split it up into three projects from low-level to top android specific level like that: engine, game, android game.
所涉及的类/错误的接口可:
The involved classes/interfaces in the error are those:
-
(低电平)发动机项目定义了这个接口:
(low level) engine project defines this interface:
com.myteam.engine.IGame
(中等水平)平台的独立游戏项目定义这些类:
(mid level) platform independent game project defines those classes:
com.myteam.myproject.Game
com.myteam.myproject.MyProject (derived from com.myteam.myproject.Game)
(顶层)的Android项目实施活动等。
(top level) android project implements activity, etc.:
com.myteam.myproject.android.MyAndroidActivity (using com.myteam.myproject.MyProject)
所有编译以及和Windows下运行完美(与3级另一个Windows项目采用前两种)。
All compiles well and runs perfectly under Windows (with another Windows project on level 3 using the first two).
但随着ADT运行时,它无法在运行时的活动开始时。 Android应用程序基本上只是显示一个调用堆栈与NoClassDefFoundError的com.myteam.myproject.MyProject异常。
But when running with ADT it fails at run-time when the Activity starts. The Android app basically just displays a call stack with a "NoClassDefFoundError com.myteam.myproject.MyProject" exception.
的例外似乎是由它的父类(或超类的接口)所引起,而加载/解析为LogCat中输出显示:
The exception seems to be caused by its super class (or the super class' interface) while loading/resolving as the LogCat output reveals:
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项目设置的其他职位和论坛进行确认,但不会改变任何事情。
I tried adding the two first projects under the "Build Path / Order and Export" Eclipse project settings of the android game project as described in other posts and forums but it doesn't change a thing.
我的直觉是,清单或项目设置需要的包/类依存关系的另一个提的APK包装或运行时间。任何想法?
My hunch is that the Manifest or Project settings need another mentioning of the package/class dependencies for apk packaging or run-time. Any ideas?
推荐答案
我有一个三层的Android / Java的应用程序,几乎就像你:
I have a three-tiered Android/Java app, almost just like you:
- 低级别的网络通信Java的唯一项目
- Java的唯一项目,以抽象的低层次项目的功能
- Android应用
以上每一点是包含在一个单一的工作区一个单独的Eclipse项目。
Each thing above is a separate Eclipse project contained in a single workspace.
下面是你需要做的:
- 在该应用程序的项目属性 - > Java构建Path->项目,添加纯Java的项目
- 在该应用程序的项目属性 - > Java构建Path->订单和出口,检查Java-唯一项目(这标志着他们为出口)
现在您的应用程序应该建立和运行,而不的NoClassDefFoundError
例外或 VFY
错误如下所示:
Now your app should build and run without NoClassDefFoundError
exceptions or VFY
errors like the following:
03-27 21:10:17.120: W/dalvikvm(420): VFY: unable to find class referenced in signature (Labstractionlayer/BaseStationManager;)
03-27 21:10:17.120: W/dalvikvm(420): VFY: unable to find class referenced in signature (Labstractionlayer/BaseStationManager;)
03-27 21:10:17.160: I/dalvikvm(420): Failed resolving Lcom/demo/log/AndroidLogWrapper; interface 253 'Lcommon/Logger/LogWrapper;'
03-27 21:10:17.160: W/dalvikvm(420): Link of class 'Lcom/demo/log/AndroidLogWrapper;' failed
03-27 21:10:17.160: E/dalvikvm(420): Could not find class 'com.demo.log.AndroidLogWrapper', referenced from method com.demo.Application.onCreate
03-27 21:10:17.160: W/dalvikvm(420): VFY: unable to resolve new-instance 218 (Lcom/demo/log/AndroidLogWrapper;) in Lcom/demo/Application;
03-27 21:10:17.170: D/dalvikvm(420): VFY: replacing opcode 0x22 at 0x0003
03-27 21:10:17.170: D/dalvikvm(420): VFY: dead code 0x0005-003c in Lcom/demo/Application;.onCreate ()V
03-27 21:10:17.170: D/AndroidRuntime(420): Shutting down VM
03-27 21:10:17.170: W/dalvikvm(420): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-27 21:10:17.180: E/AndroidRuntime(420): FATAL EXCEPTION: main
03-27 21:10:17.180: E/AndroidRuntime(420): java.lang.NoClassDefFoundError: com.demo.log.AndroidLogWrapper
顺便说一句,之前ADT R17,你只需要做上述步骤1(添加Java-唯一项目)。但是,随着R17开始,你还需要执行步骤2(用于出口标记纯Java的项目)。
BTW, prior to ADT r17, you only needed to do step 1 above (add the Java-only projects). But beginning with r17, you need to also do step 2 (mark the Java-only projects for export).
这篇关于在Eclipse中/ ADT与项目相关性(无法分辨XY)的Android活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!