I'm writing an Android application and would like to create two versions based on the same code -- a free and a premium version. I have one codebase for both versions with various run-time checks to enable or disable certain features, e.g.
public class MyAppContext extends Application
{
public static final boolean isPremium = true;
}
// later, in another file....
if (!MyAppContext.isPremium) {
CoolFeatures.setVisibility(View.GONE);
}
I'm using the latest dev tools (Eclipse Indigo with Google's ADT 16). Right now I follow a fairly cumbersome process of setting isPremium to true in my source file, exporting the app into an APK, then setting it to false and exporting it a second time into a different APK. This is both annoying and error-prone.
Is there a way to automate this process? That is,
1) Create two different build configurations so that when I export my app, two APK files are generated.
2) Have the build configuration affect the code at compile-time -- for example, setting a static boolean to true or false.
Thanks!