Question: 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.

Answer: 
Here is another solution.

1) Create an interface

```
public interface BuildVariantDetector {

    boolean isDebugVariant();

}

```

2) Use this interface on Application class (Appplication module)

```
public class MyApplication extends Application implements BuildVariantDetector {

    @Override
    public boolean isDebugVariant() {
        return BuildConfig.DEBUG; //application (main module) Buildonfig
    }

}

```

3) 
And then in library module:

```
boolean debugVariant = ((BuildVariantDetector)getApplication()).isDebugVariant();

```
In my case I was importing the wrong `BuildConfig` as my project has many library modules. The fix was to import the correct `BuildConfig` for my `app` module.