Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is BuildConfig.DEBUG?

Tags:

android

My project doesn't seem to be aware of this new constant that's apparently auto-generated in Android Tools r17 builds:

"Added a feature that allows you to run some code only in debug mode. Builds now generate a class called BuildConfig containing a DEBUG constant that is automatically set according to your build type. You can check the (BuildConfig.DEBUG) constant in your code to run debug-only functions such as outputting debug logs."

I've confirmed that this class is not being auto-generated anywhere in my project by the new tools. I deleted all project outputs (including all gen folders) and rebuilt, and only R.java classes are being generated.

Why are the tools not generating the BuildConfig class? It may be relevant that I'm using IntelliJ.

like image 379
Ollie C Avatar asked Mar 22 '12 12:03

Ollie C


People also ask

What is BuildConfig in Android?

BuildConfig is a class containing static constants that is included in every Android application. BuildConfig includes some default fields such as DEBUG and FLAVOR but you can also add custom values via build.

What is BuildConfig class?

What is BuildConfig? Gradle generates a BuildConfig class that contains static configuration constants that are specific to the build at build time. The class includes default fields such as debug and flavor, but you can override them with build.

How is BuildConfig generated?

There's a class called BuildConfig. java which is automatically generated by the build system. This class is updated automatically by Android's build system (like the R class). It already contains a static final boolean called DEBUG, which is normally set to true.


1 Answers

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.

like image 184
David Snabel-Caunt Avatar answered Sep 21 '22 13:09

David Snabel-Caunt