Alex1987
Alex1987

Reputation: 9457

Android build flags?

I'm building an android app with 2 versions of paid and free. Basically I have a library project with all the logic and 2 skeleton projects for each version. Now I need some kind of build flags to distinguish between the versions. Is this possible?

Upvotes: 5

Views: 1090

Answers (1)

inazaruk
inazaruk

Reputation: 74790

You actually do not need build flag for that. Here is how you can achieve this:

  1. In your Library Project define resource: <bool name="type.free">true</bool>
  2. In your application that is supposed to be free: <bool name="type.free">true</bool>
  3. In your application that is supposed to be paid: <bool name="type.free">false</bool>

And then at any point in your Library Project you can check the value of Boolean resource and decide what you need to do. Of cource, you'll need access to Context object for this.

Upvotes: 6

Related Questions