In C++ I would normally setup 2 builds - debug and release with each having DEBUG
and RELEASE
predefined respectively. I would then use these defin
There's no (by default) any preprocessor for Java, so no #ifdef
stuff at compile time. But if you do not mind leaving debug code in your app, then you can check if app is release or debug at runtime with this code:
Boolean release = (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE);
which checks debuggable
flag value. And said flad is automatically set to false
for release builds and true
for debug builds.
If you want to get rid of some debug code, you may try using ProGuard to strip certain classes or methods. And by default ProGuard is involved in building process for release builds only.