Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Product Flavor returned as empty always

In my gradle(app) file, I am setting the Product flavor and build type as shown below

productFlavors {

    mock {

    }

    develop {

    }

    qa {


    }
    staging {

    }
    prod {

    }
}

buildTypes {

    debug {
        //signingConfig signingConfigs.release
    }
    release {
        minifyEnabled false
        //signingConfig signingConfigs.release
    }

In Android studio build variants, I get the following options based on the above:

  • developDebug
  • developRelease
  • mockDebug
  • mockRelease
  • prodDebug
  • proddRelease
  • qaDebug
  • qaRelease
  • stagingDebug
  • stagingRelease

I have put a code in my app to print the current running Build variant as below. But the below code always print empty. Why is this so? How can I get the exact build variant inside my app? Any help is much appreciated.

System.out.println("Current build variant is"+BuildConfig.FLAVOR);
like image 549
user264953 Avatar asked Nov 30 '22 15:11

user264953


1 Answers

You probably imported the wrong BuildConfig. Check your imports and see if it is:

import <your_package_name>.BuildConfig;

and NOT something like:

import android.support.v4.BuildConfig;
like image 131
Dumitru Hristov Avatar answered Dec 04 '22 12:12

Dumitru Hristov