BuildConfig.DEBUG always false when building library projects with gradle BuildConfig.DEBUG always false when building library projects with gradle android android

BuildConfig.DEBUG always false when building library projects with gradle


With Android Studio 1.1 and having also the gradle version at 1.1 it is possible:

Library

android {    publishNonDefault true}

App

dependencies {    releaseCompile project(path: ':library', configuration: 'release')    debugCompile project(path: ':library', configuration: 'debug')}

Complete documentation can be found here http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication

EDIT:

The issue has just been marked as fixed for the Android Studio Gradle Version 3.0. There you can just use implementation project(path: ':library') and it'll select the correct configuration automatically.


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


Check for imports, sometimes BuildConfig is imported from any class of library unintentionally.For example:

import io.fabric.sdk.android.BuildConfig;

In this case BuildConfig.DEBUG will always return false;

import com.yourpackagename.BuildConfig;

In this case BuildConfig.DEBUG will return your real build variant.