views:

48

answers:

3

I am about to embark on a project for android that will have a free version and a premium version.

In VC++ land you would do this by adding preprocessor tags around the premium sections (or where the code would enter a premium section).

I could have two projects with separate source trees, but a bug in one would require a fix in the other.

However in Java you don't have a preprocessor so how do I go about this? Say you have a screen with an additional button that is the premium feature how would that be handled?

I will be using Eclipse as my IDE so Eclipse-centric answer appreciated.

A: 

If it's just a about buttons or other View-components you could simply hide them in the "lite" version, like

public static final boolean LITE_VERSION = true;

... 

if (LITE_VERSION) {
   premiumButton.setVisibility(View.INVISIBLE);
}
Martin
A: 

I would rather put the advanced things in another jar and use IOC to query for these rather than rely on a if(bool) for this.

For you lite version, you just don't distribute the premium jars.

Florian Doyon
This would make it pretty easy to bypass once someone gets their hands on the premium jar.
Robin
That's easy to overcome when you don't have sales ;)
Florian Doyon