I have an OpenGL engine that I made for Android as a separate project. In the past, to make stuff using the engine, I would just clone that project and add the game code alongside the engine code, but now I'm trying to make it more organized by having the engine code in one project and the game code in another project. Doing so would allow me to work on both the game AND the engine at the same time without having a bunch of packages and code in one project(that is, of course, assuming its possible)
My background is in C++ so the way libraries and linking and stuff is done in Java is new to me. Heres what I did:
I have the engine project "fooEngine" and the game "barGame"
fooEngine has the packages com.fooEngine.blahblahblah with the engine code I need to use to make a game
in the barGame properties I went to "Java Build Path -> Projects -> Add" and added fooEngine. This allowed me to use the packages and code from fooEngine in the barGame project.
Everything was nice and peachy up to that point, but when I run it I get a noClassDefFound exception.
Can someone help me sor开发者_运维百科t this out :(
I had this same issue. In order to fix it, I had to go to my project's build path properties, then click the right-most tab, "Order and Export" and check the checkbox next to each of the referenced external projects. Not sure why I had to do this, but that is what fixed it for me.
Depending on how you start the app, you need to set the classpath to include both projects. Or, build both projects into a single jar whihc you deploy to Android.
精彩评论