简体   繁体   中英

Where is BuildConfig.DEBUG?

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.

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.

I've just checked. It is generated here (in all your projects):

gen/package_name/BuildConfig.java

And contains the following:

/** Automatically generated file. DO NOT MODIFY */
package package_name;

public final class BuildConfig {
    public final static boolean DEBUG = true;
}

IntelliJ Idea now supports generating of BuildConfig in newest EAP

Relevant links:

http://youtrack.jetbrains.com/issue/IDEA-83336 http://confluence.jetbrains.net/display/IDEADEV/IDEA+11.1+EAP

IntelliJ apparently doesn't support generation of this file. I use IntelliJ to edit my code but ant to compile it, and the BuildConfig stuff is being generated for me. So you could either wait for IntelliJ to produce an update which generates BuildConfig or switch to ant for compilation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM