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?
Starting from Android Gradle Plugin 3.0 you can make following configuration in build.gradle
file:
android {
lintOptions {
fatal 'StopShip'
}
}
This will break the build as long as there exists a StopShip
comment in codebase.
Watch the exact minute of Tor Norbye's "Kotlin Static Analysis with Android Lint" talk, where he talks about the feature.
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.
Have you solved this? I know 2 years have passed, but I just found this while searching what was STOPSHIP
after finding it by accident while commenting.
StopShip
--------
Summary: Code contains STOPSHIP marker
Priority: 10 / 10
Severity: Warning
Category: Correctness
NOTE: This issue is disabled by default!
You can enable it by adding --enable StopShip
So I would say you should have executed the command in order to enable it.
You could modify the build.xml, have it read your DEBUG flag from the source and simply change the file name of the APK depending on the value. Make that name explicit enough and you will never distribute or upload the wrong APK (and you can also make it a condition for other following automated processes).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With