0

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.

graham.reeds
  • 16,230
  • 17
  • 74
  • 137

3 Answers3

2

The Android SDK formally addresses the issue of a shared or common codebase with something called a library project.

http://developer.android.com/guide/developing/eclipse-adt.html#libraryProject

Basically, the shared code is defined as a library project, then a free and a premium version are simply two different projects in your eclipse workbench, both referencing aforementioned library project.

At build-time, the library project gets merged with either of your releases, which is what you want.

The Android SDK example source code contains a project called TicTacToe that will help you get started with library projects.

Good luck.

Daniel

Daniel Szmulewicz
  • 3,971
  • 2
  • 25
  • 26
1

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
  • 4,146
  • 1
  • 27
  • 37
0

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);
}
DonGru
  • 13,532
  • 8
  • 45
  • 55