I'm developing in eclipse using ADT for android.
In my application I have some constants which help me to to debug my app easily.
As an example I have:
public static final boolean DEBUG_TOAST_LOGS = true;
which help me to toast some logs on the screen.
Each time I intend to build a release, I have to go through my
constants and set their values to what is appropriate for the release edition, which is somehow painful.
Now what I want is a way to build my app, using two configurations: one for debug mode and the other for release mode. The release mode should set my constants to the appropriate values. How cant I do that? What's your suggestion? What's the best way to accomplish my need?
Any help would be appreciated.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
I'm not sure if you are using Gradle as your build system. If you do, you can set build-type specific resources, e.g. a boolean
debug
value will betrue
for debug build type, and false for release build type.build.gradle
Application.java
@hidro's solution is fine, but requires an unnecessary
getResources()...
call each time you want to access the value.There's another possibility :
build.gradle
}
Then,in your code, you can write :