When does ADT set BuildConfig.DEBUG to false?
Currently you can get the correct behavior by disabling "Build Automatically", cleaning the project and then export via "Android Tools -> Export Signed Application Package". When you run the application BuildConfig.DEBUG
should be false.
BuildConfig.DEBUG always return false
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.
BuildConfig.DEBUG always false when building library projects with gradle
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
Why is BuildConfig.DEBUG set to false when executing local unit tests via Gradle?
I assume you have two flavors, debug
and release
.
If you run ./gradlew test
, it will run two test task which are testDebugUnitTest
and testReleaseUnitTest
.
There are simple test case like following.
@Test fun test() {
assertTrue(BuildConfig.DEBUG)
}
It will succeed in the testDebugUnitTest
task and fail in the testReleaseUnitTest
task.
Also test
task will fail.
Because test
task dependsOn testReleaseUnitTest
.
Where is BuildConfig.DEBUG?
IntelliJ doesn't generate the BuildConfig java and class files.
I assume this function is provided by the ADT plugin for Eclipse, and isn't a part of the SDK tools/common build stuff.
Is BuildConfig.DEBUG still bugged?
It seems the issue to which you are referring is specific to ADT + Eclipse. So I believe that if you're using Gradle and Android Studio, this should not be an issue.
Crucially: this only occurs if you're using the Build Automatically option, and you don't clean your project. Because of this, I would hardly consider this a bug. After all, who says what should and shouldn't be rebuilt whenever you make a code change and have Build Automatically enabled?
As a matter of good practice, you should always clean and rebuild your project prior to an actual release, in which case this is a non-issue.
So yes, this is still a problem if you're using this setting, and not rebuilding your project prior to release, and you're still using ADT and Eclipse (which seems to be destined for deprecation).
Here's the discussion of the bug: https://code.google.com/p/android/issues/detail?id=27940
how to use setDeveloperModeEnabled(BuildConfig.DEBUG) correctly?
BuildConfig.DEBUG
(in addition to everything in the BuildConfig class) is set by the Android build tools at the time your project is built. It's assigned true when it's a debug build, false for release builds. This value has nothing to do with Firebase or its SDKs.
See also this question.
Related Topics
Disabling Android's Chrome Pull-Down-To-Refresh Feature
How to Close Activity and Go Back to Previous Activity in Android
Finish an Activity After a Time Period
Coordinator Layout with Toolbar in Fragments or Activity
In HTML5, How to Keep an Android Device's Screen On
Android Back Button on a Progressive Web Application Closes De App
Does 'Meta Name="Google-Play-App"' Work
How to Implement Search in Customlistview Based on Class Item of Pojo Class in Android
Get Android .Apk File Versionname or Versioncode Without Installing APK
CSS - Background-Size: Cover; Not Working in Firefox
Bordercolor Not Picking The Lineargradient Color on Android
Using Katzer Local Notification in Ibm Worklight
Firebase Changing Layout of Child Data Information in Android