tags:

views:

75

answers:

3

I have an app, say MyApp Free. I want to create MyApp Pro which I can charge for that has some additional functionality. The obvious way is to have a library that contains almost all my app code, then two Android app projects for the Free and Pro versions which reference that library.

Suggestions?

+3  A: 

Look on my github page for the CWAC series of projects -- they all create JAR files for reuse in other projects.

In short, there's not much magical for simple JARs, other than putting the Android JAR in your build path so your code referencing Android APIs compiles.

However:

  • It is difficult to share resources. I am working on a solution for that now.
  • You can have components (activities, services, etc.) in the JAR, but the apps themselves still have to list those components in those apps' manifests
CommonsWare
Thanks for the reply. It's the resources I'm struggling with - Eclipse isn't creating my R class so I'm not getting the auto generated stuff :(
Matt
You have to copy the resources into the other two projects -- there's no way around that part. To reference them in the JAR, you cannot use `R.` syntax, since you won't have an `R.java` file. Instead, you will need to use `Resources#getIdentifier()` and cache the result. Also, the grapevine hints that there may be help coming your way on this particular application structure later in 2010.
CommonsWare
Very interesting. I didn't think of avoiding the R class. I have quite a few drawable resources so it's going to be a pain but may well work. I'll give it a go, thanks. oh and I'll eagerly await the help in the future!
Matt
A: 

For your particular situation, you could just write one project, then put a little static boolean in it that determines whether it's the free version of the paid version. I guess it doesn't really matter unless the added functionality involves a much bigger download.

Daniel Lew
That was my original plan, but I need to change AndroidManifest.xml for each build to indicate the package, version etc etc. Trying to avoid a load of hassle when I release a new version.
Matt
A: 

Another option is keeping a separate branch in your code repository for the free version, that is what I do. You do have to change AndroidManifest.xml for the free version on the free branch.

See http://stackoverflow.com/questions/2365542/2-version-software-best-vcs-approach

dweebo