Home » Android » android – Ionic2/Cordova build publish app with different features. Example: Free and Paid

android – Ionic2/Cordova build publish app with different features. Example: Free and Paid

Posted by: admin May 14, 2020 Leave a comment


I’m developing an application, where it will have a paid (full) version and a free (lite) version.

In another application developed for Android it is possible to manage this easily with flavors (productFlavors), where I can configure the replacement of any part of the application. For example: I can configure an applicationId and flag boolean PAID_VERSION, for each application as follows:

productFlavors {
    free {
        applicationId 'com.mycompany.myapp.free'
        buildConfigField "boolean", "PAID_VERSION", "false"
    paid {
        applicationId 'com.mycompany.myapp.paid'
        buildConfigField "boolean", "PAID_VERSION", "true"

And in the code I can check the PAID_VERSION flag of the following way:

boolean b = BuildConfig.PAID_VERSION;

And if I want to change the icon and application name by version I should specify in the packages (applicationId) of each flavor the specific icon replacing the default, for example:

String resource application name:

Free path: /free/res/values/strings.xml

    <string name="app_name">My App - Free</string>

Paid path: /paid/res/values/strings.xml

    <string name="app_name">My App - Paid</string>

Icon Resource:

Free path: /free/res/drawable/icon.png (Imagem Free)

Paid path: /paid/res/drawable/icon.png (Imagem Paid)


How would it be possible to have a similar configuration to that for a Ionic2/Cordova project, which is possible with the same code base generate 2 applications with a few different features, to be distributed in stores simultaneously and independently?

How to&Answers:

Well, you may have stumbled into this already, but this guy created this Gulp tasks to modify the config.xml file on build-time for this purpose.

Also in this forum topic he explains how to obtain the current version for conditional in-app code.

Another related topics are: Configure build flavors for cordova which recommends using Cordova Hooks to modify the config.xml file based on enviroment variables, as discussed in here: Using environment variables / parameterizing config.xml