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



Question:

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?


Solution:1

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


Solution:2

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.


Solution:3

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?


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »