在开发Android应用程序时,我们可以在
AndroidManifest.xml
中设置其
debug
属性,比如示例1
示例1
只有android:debuggable="true"时我们才可以在手机上调试Android程序。
但是当我们没在
AndroidManifest.xml中设置其debug属性时:
使用Eclipse运行这种方式打包时其
debug属性为
true
,
使用Eclipse导出这种方式打包时其
debug属性为法false.
在使用ant打包时,其值就取决于ant的打包参数是release还是debug.
因此在
AndroidMainifest.xml
中最好
不
设置
android:debuggable
属性置,而是由打包方式来决定其值。。
当然对于测试人员还是应该检查该属性的,比如
使用aapt工具:
aapt list -v -a myfile.apk
这个命令将会打印和apk相关的所有详细信息,找到“android:debuggable",它的值分为:
0x0: debuggable false
0xffffffff: debugabble true
例如,在我的测试中,这一行的信息是:
A: android ebuggable(0x0101000f)=(type 0x12)0x0
这说明我的Release Build已经关闭了debuggable!
另外,还有一种测试方法:
使用android cts测试,http://source.android.com/compatibility/cts-intro.html
这是一种单元测试的方法,具体用到的类是android.permission.cts.DebuggableTest。
testNoDebuggable:如果是true,说明debuggable false;
testNoDebuggable:如果是false,说明debuggable true。
当然,我们也可以在Android应用程序中来判断当前应用是否处于debug状态来做一些操作,如
示例2。
示例2
另外,我们也可以在Android应用程序中来判断当前其他应用程序是否处于debug状态,如
示例3。
示例3