Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple dependent android projects in eclipse

I just started to play with android dev and java+eclipse is pretty new to me. I managed to create simple project and run it on my device. Now I want to create simple game (more of them actually) and I would love to use shared code base for all of them (game loop, initialization, etc..).

Problem is that I have no idea how to correctly do this. I created android project called engine with all basic stuff that I need and made it work on device. Now I tried to create another project in same workspace called mygame. Main class (activity) of mygame is MyGameApp which inherits from EngineApp (main activity of my engine project) which inherits from Activity.

I added engine project into required projects in mygame build path tab in properties. Problem is that when I try to run this project it crashes on ClassNotFoundException trying to find my MyGameApp class.

Any help (or pointer to some articles that explain how this is done) is greatly appreciated. few hours of googling didn't help much :/

like image 532
Lope Avatar asked Jun 14 '10 21:06

Lope


1 Answers

You need to set up an Android Library Project

An Android library project is a development project that holds shared Android source code and resources. Other Android application projects can reference the library project and, at build time, include its compiled sources in their .apk files. Multiple application projects can reference the same library project and any single application project can reference multiple library projects.

The docs go on to say how to convert an existing project to a library project:

You can also convert an existing application project into a library. To do so, simply open the Properties for the project and select the "is Library" checkbox. Other application projects can now reference the existing project as a library project.

like image 71
Stephen Denne Avatar answered Oct 02 '22 19:10

Stephen Denne