views:

126

answers:

2

I want to build two Android apps from the same code base. The difference between the apps is very small - app name, one or two resource files, and whether to show ads or not (basically, a free and a paid version of the same app).

This is pretty simple to do in XCode for an iPhone app, but I'm not sure how to approach it in Eclipse. Is there a clean way to do it, or should I forget about Eclipse completely and dive into the Ant scripts?

A: 

Use 3 Eclipse projects. One for everything that's common (and possibly all of your Java code) and then one for each of the applications, where you just inherit from the common one (and have your different resource files, etc).

Francis Upton
+1  A: 

As mentioned in the other answer, create another eclipse project with the common code as well as a project for each variation.

The common code project does not have to be an android project. This is ideal because it doesn't have any of the overhead of the Android project and hence will be more flexible. If the common code has any android related code, you will need to include android.jar, which is inside the directories of the android development kit.

To make it all work together, setup an Eclipse project dependency between the new projects and the common code.

gregm
Thanks for the answer, this makes sense. I've been running into a few problems, though. If I try to set up the common code in a non-Android project, I now no longer have a R.java file, which breaks the build. If I leave the common code as an Android project and reference it from a new project, the build scripts seem to build and install the referenced project as an .apk first, which doesn't make sense. Have you managed to get it to work?
alex_c