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)
(top level) android project implements activity, etc.:
com.myteam.myproject.android.MyAndroidActivity (using com.myteam.myproject.MyProject)
All compiles well and runs perfectly under Windows (with another Windows project on level 3 using the first two).
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.
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)
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.
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?
I have a three-tiered Android/Java app, almost just like you:
Each thing above is a separate Eclipse project contained in a single workspace.
Here's what you need to do:
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
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).