Android Studio supports Gradle for doing the actual building of the app. There’s a class called BuildConfig.java which is automatically generated by the build system. This class is updated automatically by Android’s build system (like the R class).
It already contains a static final boolean called DEBUG, which is normally set to true.
The simple explanation is that default values are set initially before Proguard is run, then after Proguard runs, the BuildConfig file is regenerated with the proper values. However, Proguard has already optimized your code by this point and you have issues.
ProGuard is a free Java class file shrinker, optimizer, obfuscator, and preverifier. It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions. For more details.
How to customize BuildConfig and create your own variable accordingly
Step 1. Create your field in your build.grab,
12345678910 productFlavors {defualt {applicationId "webkul.mobikul.demoapp"buildConfigField "boolean", "IS_DEFAULT_FLAVOR", "true"}Flavor1 {applicationId "webkul.mobikul.demoapp2"buildConfigField "boolean", "IS_DEFAULT_FLAVOR", "false"}}
Step 2. In your BuildConfig.java define,
1 public static final boolean IS_DEFAULT_FLAVOR = false;
Step 3. You can use it anywhere in the app,
123 if (!BuildConfig.IS_DEFAULT_FLAVOR) {//your code}
Thank you maybe, this blog is useful for you.