In C++ I would normally setup 2 builds – debug and release with each having DEBUG and RELEASE predefined respectively. I would then use these definitions to determine constant values, like logging enabled/disabled, server URL and etc.
Right now, in Java/Android I comment out some stuff before building release. That is not a good way, I can tell. I may forget something.
What is a common practice for ensuring nothing is forgotten when building a release version (signed) or debug version (unsigned)?
There’s no (by default) any preprocessor for Java, so no
#ifdefstuff 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:which checks
debuggableflag value. And said flad is automatically set tofalsefor release builds andtruefor 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.