在这里找到一篇好文章:http: //tekeye.biz/2013/android-debug-vs-release-build。
也进行了测试。如果我们强制android:debuggable="false"
或android:debuggable="true"
在清单应用程序上,它会警告:
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.
我会得出结论,在默认情况下,ApplicationInfo.FLAG_DEBUGGABLE
行为与 相同BuildConfig.DEBUG
,除非通过更改覆盖android:debuggable
,这是不可取的。
相比BuildConfig.DEBUG
,ApplicationInfo.FLAG_DEBUGGABLE
是一种更可靠的检查调试版本的方法,因为在较低的依赖模块中,它无法访问BuildConfig.DEBUG
父模块的 ,并且可能具有不同的值。
例如 App 使用 MyLib 模块。AppBuildConfig.DEBUG
可能是假的,但 MyLibBuildConfig.DEBUG
可能是真的。因此最好检查使用ApplicationInfo.FLAG_DEBUGGABLE