There is a new way to determine is it a debug build or release one in SDK Tools, Revision 17. An excerpt from new features overview:
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.
So now you can simply write something like this:
if (BuildConfig.DEBUG)
{
//Your debug code goes here
}
else
{
//Your release code goes here
}
UPDATE: I’ve encountered bug in ADT: sometimes BuildConfig.DEBUG
is true
after exporting application package. Description is here: http://code.google.com/p/android/issues/detail?id=27940