Found a good article here: http://tekeye.biz/2013/android-debug-vs-release-build.
Also tested it out. If we force android:debuggable="false"
or android:debuggable="true"
on Manifest Application, it will warn :
Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one less...
It's best to leave out the android:debuggable attribute from the manifest. If you do, then the tools will automatically insert android:debuggable=true when building an APK to debug on an emulator or device. And when you perform a release build, such as Exporting APK, it will automatically set it to false.
If on the other hand you specify a specific value in the manifest file, then the tools will always use it. This can lead to accidentally publishing your app with debug information.
I would conclude, in default situation ApplicationInfo.FLAG_DEBUGGABLE
behave the same as BuildConfig.DEBUG
, unless override by changing android:debuggable
, which is not something advisable.
Compare to BuildConfig.DEBUG
, ApplicationInfo.FLAG_DEBUGGABLE
is a more reliable way to check for debug build, as at a lower dependent module, it can't access the BuildConfig.DEBUG
of the parent module, and could have a different value.
e.g. App use MyLib module. App's BuildConfig.DEBUG
could be false, but MyLib BuildConfig.DEBUG
could be true. Hence it's better to check using ApplicationInfo.FLAG_DEBUGGABLE