Reputation: 1717
I do an application in two versions: premium and free. Now for me the functional of premium version works after verification of:
if (isPremiumVersion){
//to do premium fuctions
}.
But I do not think that it is good tone. How is it possible to divide these two versions, that they were independent of each other? Only at the start of application to do verification, and then already, for example, to start the certain manifest file with a certain package, and classes. Unfortunately, does not turn out to find material, how more correct to do it.
Upvotes: 0
Views: 186
Reputation: 25836
What you need is Product flavors.
You can define them in build.gradle
:
android {
....
productFlavors {
free {
applicationId 'com.myapp.free'
}
premium {
applicationId 'com.myapp.premium'
}
}
}
For each product flavor you can create it's own source set by creating directory with name of flavor in app src
directory so your app structure will be like:
src/
main/
free/
premium/
You can add customized AndroidManifest.xml
, resources and sources in flavor source sets and they will be merged with main
source set.
You should carefully read official documentation at link I mentioned above. There much more possibilities and details then I described here.
Upvotes: 1