关于AndroidManifest.xml中的android:debuggable

本文详细介绍了如何通过命令行工具和单元测试方法来检查Android应用在AndroidManifest.xml中是否开启了调试模式,以及如何在应用内代码中获取此设置的值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[color=blue][b]在AndroidManifest.xml中,<application>可以设置attribute android:debuggable,其值为“true”或“fasle”。

在官方文档中对它的说明如下:

Whether or not the application can be debugged, even when running on a device in user mode — "true " if it can be, and "false " if not. The default value is "false ".

那么如何获知它的设置值呢?下面的可以提供了解。



1. 如何测试APK是否设置android:debuggable="false"

在此blog中介绍的两个方法。

第一种用于对apk文件的检测。使用下面的命令(在Ubuntu中示例):

aapt list -v -a apk文件名 |grep debuggable

得到如下输出:

A: android:debuggable(0x0101000f)=(type 0x12)0x0

这表示 android:debuggable="false"


第二种为单元测试的方法(此方法还未尝试)。其原文如下:

另外,还有一种测试方法:

使用android cts测试,http://source.android.com/compatibility/cts-intro.html

这是一种单元测试的方法,具体用到的类是android.permission.cts.DebuggableTest。

testNoDebuggable :如果是true,说明debuggable false;

testNoDebuggable :如果是false,说明debuggable true。


2. [打包、发布] 程序如何知道当前的apk包是不是处于debuggable

此贴中讨论的是在程序自身运行时获取设置值。关键点可以从贴中引用的一段话体现:

Now you can check this attribute's value from your code by checking the ApplicationInfo.FLAG_DEBUGGABLE flag in the ApplicationInfo obtained from PackageManager. [/b][/color]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值