Recent Posts

Site Creator

Product Flavours in Android

Posted on

Dear Friends

This article targets those users those have released a Free app in Google play store or going to release a Free app in Google Play store and in future they are planning to release a Paid version of the app.

For getting an overview of a process to release an app on play store please refer to one of our blog tutorial Link

Lets start with our work.

We need to some configuration in app.gradle file and android studio will help us in generating product flavours.

Below is a typical app.gradle file for an android project .

So in the above file you see a code snippet called productFlavours. Suppose you have an app having some features. Now you want to develop another similar app having few different features.

It doesn’t make any sense to develop another app for just few features of app. The biggest problem we are going to face is app management. Now we need to manage two different apps [ means two different code bases]. Now if you have to frequently update your two apps so everytime you need to make code changes to two code bases. And if you are planning to update your apps three times a week so now you know what the kind of mess it will be there if there are two bases.

Any application developer is in such a scenario must have faced this problem or will be facing this problem. So if somehow if we have a single code base which can generate two different types of apk as per requirement that would be great. So how to do that.

Refering to above gradle file, please read below

buildConfigField params may be different for diffenent product flavours. You will access them in your java code base and can modify application behaviour on the basis of these params. For eg. psuedo code…

if (buildconfig .. is this )
do this
else
do this

Rest android studio will generate different apks for different product flavours as per your requirement.

Now you see you have a single code to generate multiple apks.

Very soon we will be adding a video soon for to see all this in action.

For more information regarding this visit do visit Android Developer site Page : link

Thanks







Disclaimer: The aforesaid writeup by Relsell Global writer is for the general understanding of the readers. It does not render any professional advice or opinion.

SHARE THIS PAGE!