Why does BuildConfig.DEBUG
return false, when I run the application?
I use it to control the log like the following:
public static void d(String LOG_TAG, String msg){
if(BuildConfig.DEBUG){
Log.d(LOG_TAG,msg);
}
}
Why does BuildConfig.DEBUG
return false, when I run the application?
I use it to control the log like the following:
public static void d(String LOG_TAG, String msg){
if(BuildConfig.DEBUG){
Log.d(LOG_TAG,msg);
}
}
In your Android Studio build variant are you on debug variant?
That is applied when you use
flavors
, either fordebug
orrelease
.in the debug mode,
BuildConfig.BUILD
is true, and in the release mode, it is false.Check imports in the class, make sure you are using correct BuildConfig path. You may use BuildConfig not from your app, but from some library.
I specified
debuggable true
in build.config, but this was always falseAfter this change, all was working properly :
If that code is in a library, then it'll always be false, thanks to a 3-year-old bug in gradle.
Maybe you are importing the wrong package, check that. (some Android libraries also have the BuildConfig class)
There is a workaround for the problem:
App
Library