Android Studio will automatically add the BuildConfig class. This class has a field called DEBUG. Its value is automatically generated based on the current compilation mode. When the compilation mode is debug, the value is true, and when the compilation mode is release, the value is false. Therefore, you can add the if (BuildConfig.DEBUG) class to the function based on this feature to achieve similar functions. A common example is to customize the Log class so that the log is output during debug and not output during release:
public void d(String tag, String message) {
if (BuildConfig.DEBUG) {
Log.d(tag, message);
}
}
No, Java does not support macro definition, and all debugging information will be included in the compilation result. You can only set variables in the program so that the debugger will not be executed in the production environment. There is version information in the Android Manifest. Debug and Release versions are produced by default. You can switch parameters through program judgment.
This function is very useless. You can obviously write code to implement it yourself (it can be done with no more than 3 lines of code). It has to be implemented natively in Android. If you want, Android development will be more complicated. We need to remember more useless functions. It’s functional (the gain outweighs the loss)
Android Studio will automatically add the BuildConfig class. This class has a field called DEBUG. Its value is automatically generated based on the current compilation mode. When the compilation mode is debug, the value is true, and when the compilation mode is release, the value is false. Therefore, you can add the if (BuildConfig.DEBUG) class to the function based on this feature to achieve similar functions. A common example is to customize the Log class so that the log is output during debug and not output during release:
No, Java does not support macro definition, and all debugging information will be included in the compilation result. You can only set variables in the program so that the debugger will not be executed in the production environment.
There is version information in the Android Manifest. Debug and Release versions are produced by default. You can switch parameters through program judgment.
Variable values can be dynamically set during AS debugging~
This function is very useless. You can obviously write code to implement it yourself (it can be done with no more than 3 lines of code). It has to be implemented natively in Android. If you want, Android development will be more complicated. We need to remember more useless functions. It’s functional (the gain outweighs the loss)
Can be achieved using BuildConfig
Yes, use gradle to configure: variables, version information
Look at the debugging skills of android studio, http://weishu.me/2015/12/21/a..., don’t be too awesome