ADT (R17) adds a new function that allows developers to only allow some code in debug mode. The build system generates a class named buildconfig, which contains a DEBUG constant, which is automatically set based on your build type. You can use the (buildconfig. Debug) constant to compile the code that runs only in debug mode.
If some code does not want to be executed after release, you can use this function.
For example, you do not want to see debugging logs after the software is released by other developers. In the past, you set a global variable to mark the software as the debug mode or the release mode.
public static boolean DEBUG = true;
Then write in the code
if(DEBUG==true){ Log.d(TAG,"output something"); }
In this way, you need to modify the value of the debug variable before packaging and publishing. Sometimes you don't remember to re-compile and release the variable, which is very time-consuming.
With buildconfig. debug, you can directly write
if (BuildConfig.DEBUG) { Log.d(TAG, "output something"); }
Before release,
The value of buildconfig. debug is automatically true,
In the package published by Android tools> export signed application package,
The value of buildconfig. debug is automatically set to false.
Developers do not need to modify anything else.