Search code examples
androidandroid-log

BuildConfig.DEBUG always return false


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);
    }
}

Solution

  • In your Android Studio build variant are you on debug variant?

    That is applied when you use flavors, either for debug or release.

    in the debug mode, BuildConfig.BUILD is true, and in the release mode, it is false.