andy mcevoy
andy mcevoy

Reputation: 388

Using other projects in Android project

I'm messing around with this book and can't figure out the proper way to set up the projects.

They tell you to make 3 projects which I've named:

To get the snake game to work I've just copied the packages from the other two projects and pasted them into the snakeGame2 project. What's the proper way to include these into snakeGame2 so that I don't have multiple copies all over the place and can reuse the projects for a different game?

The pic below shows the tree after trying to export the java source files and resources and then adding the jar to the build path of snakeGame2. For the exports, I only selected the source folder.

eclipse tree

edit: using dumpstate's answer I get this in the logcat: logcat

another edit: dumpstate's answer worked but it's incredibly slow compared to when I just copied the packages into the project. Is this a byproduct of including them in this manner?

Upvotes: 0

Views: 47

Answers (2)

andy mcevoy
andy mcevoy

Reputation: 388

I ended up linking the source folders from the other projects following this page

This method didn't have the slow downs I observed when doing libraries and jars.

Upvotes: 0

Albert Sadowski
Albert Sadowski

Reputation: 642

If AndroidFramework2D and AndroidFramework2DImplementation are ordinary Java projects:

Right click on the project > Build Path > Configure Build Path > Java Build Path > 'Projects' tab > Add.. > Choose the project you'd like to depend on.

If AndroidFramework2D and AndroidFramework2DImplementation are Android projects, they should be set as library projects (Configure Build Path > Android > check 'Is library') and the snakeGame project should refer to them (Configure Build Path > Android > Library > Add; decribed here: developer.android.com/tools/projects/projects-eclipse.html)

Upvotes: 1

Related Questions