buildTypes {
debug {
signingConfig signingConfigs.release
//标志是否需要打印日志
buildConfigField('boolean', 'NEED_PRINT_LOG', 'true')
}
release {
signingConfig signingConfigs.release
buildConfigField('boolean', 'NEED_PRINT_LOG', 'false')
}
}
会在app->build的BuildConfig中生成
// Fields from build type: debug
public static final boolean NEED_PRINT_LOG = true;//debug模式
使用:
public static void i(String msg) {
if (BuildConfig.NEED_PRINT_LOG) {
Log.i(DEFULT_TAG, msg);
}
}