The power of BuildConfig
BuildConfig is a file generated automatically when we compile an Android application. This file, by default, looks like follows:
BuildConfig contains a field called DEBUG, that indicates whether the application has been compiled in debug mode or not. This file is highly customizable, which is very handy when we work on different build types.
An application typically tracks its behaviour using Google Analytics, Crashlytics or other platforms. We might not want to influence those metrics when we are working on the application (imagine a User Interface test, automatically released every day, tracking your login screen?). We also might have different domains depending on our Build (for instance development.domain.com, staging.domain.com…) that we want to use automatically. How can we do this cleanly? Easy! In the field buildTypes of Gradle we can just add any new field we want. Those fields will be later available through BuildConfig (this means, using BuildType.FIELD we can read them).
In this post I showed how to use different icons and how to change the package name. Using this we can install different versions of our application. This is very handy to be able to see our beta, alpha and release versions at the same time.
source : https://medium.com/
No comments: