0

I am building an android application and I want to split it into two versions, Pro and Free.
The pro app will be the complete ad-free, and the free will be limited and with ads. The base of the business logic of the two apps will be the same... So I don't think that is correct to "write the code" twice. Handling same code in two projects can be very annoying for bug fixing and code improvements.

Is there any way to do it with one project?

Shared-preference for example is not good solution for this because many people have root access so they can change it very easily.

William Pursell
  • 204,365
  • 48
  • 270
  • 300
nrofis
  • 8,975
  • 14
  • 58
  • 113

3 Answers3

4

Firstly Hello,

As far as I've heard or seen, two versions of the same app (Free and Pro) should be two distinct projects. You could, but should NOT, use the same app and just check for a flag saved in the Prefs, but root users can override that (as you already stated).

You could also use Google's in App purchase to verify this as the other answer states. In my opinion you should not use the same project and check for a flag because it's bound to create some overhead, especially if you check using the Internet. If the user has a slow or unreliable network connection his experience will suffer.

The "clean" way to do it is to make two distinct apps like everyone else does: users can install the free app, or the pro app. This is ideal because you have two distinct options for users and if they want the pro version they don't need to get the free one and then see the option unlock in the menu. It's just way more straightforward for users.

I recommend you build the pro app first and after it is completed derive the free version by restricting functionality and including adds because it's easier to strip it down than to add-in. After you finish the pro version, just click on:

File -> New -> Project (pop up menu appears) -> select Android folder -> select "Android Project from Existing Code" -> select your App and click Finish

The drawback is that if you spot a bug you must fix it in both projects. If you want to optimize finding bugs, you could build the free version, put it on the market and fix the bugs reported by the end-users as well as the ones you spot. After you consider everything to be fine, you can create the pro version from the existing code and carry on with that.

ps: I realize I filled this whole page, but this is my first answer here and it seems I'm overenthusiastic :-)

George
  • 628
  • 6
  • 13
  • What is the `Google's in App purchase`? Can you please add reference to some article about it an how to use it? – nrofis Sep 25 '13 at 11:22
  • More details about this here: [In-app Billing Overview](http://developer.android.com/google/play/billing/billing_overview.html) – George Sep 25 '13 at 11:25
  • Thanks. Correct me if I'm wrong its not like to make flag? It use Google Play as flag of pro and free version, is'nt it? – nrofis Sep 25 '13 at 11:54
0

How about using Google's in App purchase? This way the Google server manages the PRO/Trial detail. The only con is that your app needs to have internet access for validation purpose :)

prijupaul
  • 2,076
  • 2
  • 15
  • 17
0

I'm sorry if this solution seems a bit raw, but... Why not have a hard-coded flag in your code... some static variable in some class saying something like:

public static final boolean isFreeVersion = true/false;

Then, in any place where you want to decide whether or not to show adds, simply reference this boolean.

You'll still need to build your app twice and publish it to the store twice (under different app signatures), once with the boolean as true, and once as false. But at least the code base will be the same. This way, if you find a bug, you can fix it, and just publish the same app twice with only switching the boolean value.

I'm pretty sure you could even find an ant script to change the value of the boolean for you during a build.

Gil Moshayof
  • 16,633
  • 4
  • 47
  • 58