BuildConfig.DEBUG is not working (= logically set to false) when I run my app in debug mode. I use Gradle to build. I have a library project where I do this check. BuildConfig.java looks like this in the build debug folder:
/** Automatically generated the file. DO NOT MODIFY */
package common.myProject;
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
}
and in the release folder:
public static final boolean DEBUG = false;
both in the library project and in the application project.
I tried to get around this by checking a variable which is set a class of my project. This class inherits from the library and starts on startup.
<application
android:name=".MyPrj" ...
This leads to another problem: is that I use my DEBUG variable in a DataBaseProvider which runs before the application class, and it will not run properly due to this bug.
This is expected behavior for this.
Library projects only publish their release variants for consumption by other projects or modules.
We're working at fixing this but this is non trivial and requires a significant amount of work.
You can track the issue at https://code.google.com/p/android/issues/detail?id=52962