Android“可调试"默认值 [英] Android 'debuggable' default value

查看:128
本文介绍了Android“可调试"默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从代码中获取应用程序的可调试属性值:

I am trying to get application's debuggable attribute value from code:

packageInfo = context.getPackageManager().getPackageInfo(packageName, 0);           
int flags = packageInfo.applicationInfo.flags;
isDebugMode = (flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;

并且我注意到,当清单中未指定debuggable属性时,此代码将其定义为true.并且文档说默认情况下它是错误的.

And I have noticed that when debuggable attribute is not specified in manifest this code defines it as true. And documentation says that it is false by default.

怎么了?

推荐答案

来自 SDK工具 :( SDK工具,修订版8(2010年12月))

From SDK Tools : ( SDK Tools, Revision 8 (December 2010) )

支持真正的调试版本. 开发人员不再需要添加 android:debuggable 属性 清单中的 <application> 标记- 构建工具会自动添加属性.在Eclipse/ADT中,全部 假定增量构建为 调试版本,因此工具会插入 android:debuggable="true" .什么时候 导出签名发布版本, 这些工具不会添加属性. 在Ant中, ant debug 命令 自动插入 android:debuggable ="true" 属性, 而 ant release 则没有.如果android:debuggable ="true"是手动的 设置,那么 ant release 实际上会 调试版本,而不是发行版 构建.

Support for a true debug build. Developers no longer need to add the android:debuggable attribute to the <application> tag in the manifest — the build tools add the attribute automatically. In Eclipse/ADT, all incremental builds are assumed to be debug builds, so the tools insert android:debuggable="true". When exporting a signed release build, the tools do not add the attribute. In Ant, a ant debug command automatically inserts the android:debuggable="true" attribute, while ant release does not. If android:debuggable="true" is manually set, then ant release will actually do a debug build, rather than a release build.

这篇关于Android“可调试"默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆