Different code in different build variant
android, android-build-flavors, android-productflavors
Solution
Build variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors. Although you do not configure build variants directly, you do configure the build types and product flavors that form them.
if(BuildConfig.Flavor.equals("customConfig"))
{
}
else
{
}
Read Building multiple flavors of an Android
Problem
I have two build variants in my app, one is an standard app edition and the second one is a customization app. ``` productFlavors { customConfig { minSdkVersion 14 applicationId 'es.com.custom' targetSdkVersion 22 versionCode 3 versionName '3.0.0' } standard { minSdkVersion 14 applicationId 'es.com.standard' targetSdkVersion 22 versionCode 3 versionName '3.0.0' } ``` For the customization I have to implement new features, but just for the customization, so those new features will be not available on the standard version. I am not sure what i have to do. 1.- Two classes , one with the standard requirements and one with the custom requirements 2.- In the standard class do something like: ``` if (getPackageName()==customConfig ) // do the custom things else //do the standard things ```