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: 
As a workaround, you can use this method, which uses reflection to get the field value from the app (not the library):

```
/**
 * Gets a field from the project's BuildConfig. This is useful when, for example, flavors
 * are used at the project level to set custom fields.
 * @param context       Used to find the correct file
 * @param fieldName     The name of the field-to-access
 * @return              The value of the field, or {@code null} if the field is not found.
 */
public static Object getBuildConfigValue(Context context, String fieldName) {
    try {
        Class<?> clazz = Class.forName(context.getPackageName() + ".BuildConfig");
        Field field = clazz.getField(fieldName);
        return field.get(null);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return null;
}

```

To get the `DEBUG` field, for example, just call this from your `Activity`:

```
boolean debug = (Boolean) getBuildConfigValue(this, "DEBUG");

```

I have also shared this solution on the [AOSP Issue Tracker](https://code.google.com/p/android/issues/detail?id=52962).
Working with debuggable true in gradle file.

```
buildTypes {
  demo{
 debuggable true
    }
  live{
 debuggable true
    }
}

```