Matt
Matt

Reputation: 86

What's the recommended way of create Android libraries for use in apps?

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?

Upvotes: 4

Views: 215

Answers (3)

dweebo
dweebo

Reputation: 3272

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 2-Version software: Best VCS approach?

Upvotes: 0

Dan Lew
Dan Lew

Reputation: 87430

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.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006664

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

Upvotes: 3

Related Questions