Sunday, March 20, 2011

Managing multiple versions of an Android app

When developing an Android app you may find yourself in a situation where you want to publish two different versions - one basic version that is free and a fully-featured version that isn't.

The free version is the marketing "hook" to get people to buy your full version - this is the tactic I am taking with Sythe, and that I took with Beat Dialer.

The obvious problem is that you end up with two codebases that undoubtedly share the vast majority of their code - requiring error-prone double-entry of any changes to common code. Here is the technique I am using to help mitigate the effects of this problem.

Firstly - this is what you'll probably have in your Eclipse Package Explorer:

Two identical hierarchies of code, the differences between versions limited to a few files in the "src" directory.
The key thing here is that I have broken the code up into "common" and "tests" packages, separate from the main "free" or "full" packages. In the filesystem these packages are different folders - allowing me to use Symlinked folders to share the "common" and "tests" code between the two projects:

I've also Symlinked the "drawable-*" folders in "res"

Whilst I obviously still have to test each project after an update, I no longer have to re-enter the same code in each - a major reducer of errors.

I how this helps you out with you projects - let me know if you have any suggestions for working with cross-project share code.