A new feature has been added to ADT (R17) that allows developers to allow only certain code in debug mode. The build system generates a class named Buildconfig that contains a debug constant that automatically sets the value based on your build type. You can use the (Buildconfig.debug) constant to write code that runs only in DEBUG mode.
If some code does not want to be executed after publishing, you can use this feature.
such as debug logs, you do not want to be seen by other developers after the release of software, the past is that you set a global variable, marking the software for debug mode or Release mode.
[Java]
- Public static boolean DEBUG = true;
Then write in the code
[Java]
- if (debug==true) {
- LOG.D (TAG,"output Something");
- }
It is time-consuming to modify the value of the debug variable before packaging the release, sometimes not remembering to recompile the release.
With Buildconfig.debug, you can write directly in the code
[Java]
- <span style="White-space:pre"> </span> if (buildconfig.debug) {
- LOG.D (TAG, "output Something");
- }
Before the release,
[Java]
- The value of Buildconfig.debug is automatically true,
You're in a package released through the Android Tools, Export signed application pack,
[Java]
- The value of the buildconfig.debug automatically becomes false.
[Java]
- The developer doesn't have to change anything else himself.
Android Buildconfig Use