Prevent code accidentally going into production

android, android-build, android-lint, lint

Solution

I've been using this flag reliably for several years now:

BuildConfig.DEBUG

It doesn't have the issues that occurred long ago, when I posted this question.

Problem

I'm looking for a simple way to make sure my `static final boolean DEBUG` flag is set to false when exporting my Android project to APK. I've tried using the "STOPSHIP" comment marker mentioned here, but it doesn't seem to have any effect on apk export, or I'm using it wrong. Building a lint extension seem an overkill for such purpose, is there a simpler way to do it? Edit Using the auto generated `BuildConfig.DEBUG` flag, combined with some hard to miss on-screen indication that you're running in debug mode (plus a mental note never to upload apk's at 4am after a quick fix) - will probably have you covered. BUT it is still not the 100% fool proof method I posted this question for. There are still complaints about `BuildConfig.DEBUG` randomly not functioning as expected. So This question is still open - is there a lint trick, or similar trick to do it?

Original source

Related problems