Create flavors of Android App on same CodeBase

In this post i will cover how to create flavors of android app like paid version and free version.


Problem with previous Solutions

  1. One way to do this is to create two codebase for your Android app. Problem with this is we have to maintain two different codebase for paid and free version which will a nightmare to maintain. If you make some change to one code then same has to be done with other code. This will be more problematic when this type of flavors increase.
  2. Other way people used to deal with this kind of problem by creating a library project for common codebase and then flavors can be created in the app which are using that library project. There were many problems related to that solution.

But with new Android Studio create flavors android app can be solved by using build flavor feature of gradle build system. You just have to create flavors of app which will pick code from common codebase and rest code from your flavor folder.

 

[su_button url=”https://github.com/androidsrc/AndroidAppFlavours” target=”blank” style=”stroked” background=”#51d461" color=”#ffffff” size=”6" center=”yes” radius=”0" icon=”icon: arrow-circle-o-down”]Download Full Source Code[/su_b[/su_button]p> 

Steps to create App flavors

For this we have declare flavors in our gradle.build file in our app module. Let us assume we want to create 2 flavor of our app . One for free version and other for paid version. In this case we have to declare 2 flavors in gradle.build file. After that we can add flavor specific compilation related code there like debug info.

GuRu

Technology enthusiast. Loves to tinker with things. Always trying to create something wonderful using technology. Loves coding for Android, Raspberry pi, Arduino , Opencv and much more.

You may also like...

2 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *