Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Updated 22 December 2016
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.
Step 1. Create your field in your build.grab,
productFlavors { defualt { applicationId "webkul.mobikul.demoapp" buildConfigField "boolean", "IS_DEFAULT_FLAVOR", "true" } Flavor1 { applicationId "webkul.mobikul.demoapp2" buildConfigField "boolean", "IS_DEFAULT_FLAVOR", "false" } } 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,
public static final boolean IS_DEFAULT_FLAVOR = false; 1 public static final boolean IS_DEFAULT_FLAVOR = false;
Step 3. You can use it anywhere in the app,
if (!BuildConfig.IS_DEFAULT_FLAVOR) { //your code } 123 if (!BuildConfig.IS_DEFAULT_FLAVOR) { //your code}
Thank you maybe, this blog is useful for you.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.