aapt常用命令

1. 列出apk包的内容

 aapt l[ist] [-v] [-a] file.{zip,jar,apk}

-v 以table形式列出来

-a 详细列出内容

 例如:aapt l <你的apk文件>,这个命令就是查看apk内容

2. 查看apk一些信息

aapt d[ump] [--values] WHAT file.{apk} [asset [asset ...]]

badging          Print the label and icon for the app declared in APK
permissions      Print the permissions from the APK.
resources        Print the resource table from the APK.
configurations   Print the configurations in the APK.
xmltree          Print the compiled xmls in the given assets.
xmlstrings       Print the strings of the given compiled xml assets.

例如:aapt d permissions <apk文件>, 这个就是显示这个apk所具有的权限

3. 编译android资源

 aapt p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] /
        [-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile] /
        [--debug-mode] [--min-sdk-version VAL] [--target-sdk-version VAL] /
        [--app-version VAL] [--app-version-name TEXT] [--custom-package VAL] /
        [--rename-manifest-package PACKAGE] /
        [--rename-instrumentation-target-package PACKAGE] /
        [--utf16] [--auto-add-overlay] /
        [--max-res-version VAL] /
        [-I base-package [-I base-package ...]] /
        [-A asset-source-dir]  [-G class-list-file] [-P public-definitions-file] /
        [-S resource-sources [-S resource-sources ...]]         [-F apk-file] [-J R-file-dir] /
        [--product product1,product2,...] /
        [raw-files-dir [raw-files-dir] ...]

这个比较复杂,只解释几个关键参数。

-f 如果编译出来的文件已经存在,强制覆盖。

-m 使生成的包的目录放在-J参数指定的目录。

-J 指定生成的R.java的输出目录

-S res文件夹路径

-A assert文件夹的路径

-M AndroidManifest.xml的路径

-I 某个版本平台的android.jar的路径

-F 具体指定apk文件的输出

例如:

1). 将工程的资源编译R.java文件

aapt package -m -J <R.java目录> -S <res目录> -I <android.jar目录>  -M <AndroidManifest.xml目录>

2). 将工程的资源编译编译到一个包里

aapt package -f  -S <res目录> -I <android.jar目录> -A<assert目录>  -M <AndroidManifest.xml目录> -F <输出的包目录>

4.  打包好的apk中移除文件

aapt r[emove] [-v] file.{zip,jar,apk} file1 [file2 ...]

例如:aapt r <你的apk文件> AndroidManifest.xml, 这个就是将apk中的AndroidManifest移除掉

5. 添加文件到打包好的apk中

 aapt a[dd] [-v] file.{zip,jar,apk} file1 [file2 ...]

例如:aapt a <你的apk文件> <要添加的文件路径>, 这个就是将文件添加到打包好的apk文件中

6.  显示aapt的版本

aapt v[ersion]

例如:aapt v, 就是打印这个结果 Android Asset Packaging Tool, v0.2


========================================================================================

aapt:Android Asset Packaging Tool , 在SDK的tools/目录下. 该工具可以查看, 创建, 更新ZIP格式的文档附件(zip, jar, apk). 也可将资源文件编译成二进制文件.

同步软件中得到apk信息就是用的这么一个android已经提供好的工具。

[html]  view plain copy
  1. aapt d[ump] [--values] WHAT file.{apk} [asset [asset ...]]  
  2.    badging          Print the label and icon for the app declared in APK.  
  3.    permissions      Print the permissions from the APK.  
  4.    resources        Print the resource table from the APK.  
  5.    configurations   Print the configurations in the APK.  
  6.    xmltree          Print the compiled xmls in the given assets.  
  7.    xmlstrings       Print the strings of the given compiled xml assets.  

使用aapt dump badging *.apk可以查看这个apk文件的程序名、包名、所用的sdk,程序版本以及权限信息等等。如下:

aapt dump bagging EngineeringTest.apk 得到如下详细信息

[html]  view plain copy
  1. package: name='com.archermind.engineeringtest' versionCode='1' versionName='1.0'  
  2. sdkVersion:'8'  
  3. application-label:'EngineeringTest'  
  4. application-icon-120:'res/drawable-ldpi/ic_launcher.png'  
  5. application-icon-160:'res/drawable-mdpi/ic_launcher.png'  
  6. application-icon-240:'res/drawable-hdpi/ic_launcher.png'  
  7. application: label='EngineeringTest' icon='res/drawable-mdpi/ic_launcher.png'  
  8. launchable-activity: name='com.archermind.engineeringtest.EngineeringTestActivity'  label='EngineeringTest' icon=''  
  9. uses-permission:'android.permission.INTERNET'  
  10. uses-feature:'android.hardware.touchscreen'  
  11. main  
  12. other-activities  
  13. other-receivers  
  14. other-services  
  15. supports-screens: 'small' 'normal' 'large'  
  16. supports-any-density: 'true'  
  17. locales: '--_--'  
  18. densities: '120' '160' '240'  

将上面的信息读入到字符串中,然后用正则表达式匹配一下。就可以把apk的信息放到同步软件中了。

另外同步软件中应该还会涉及到一些,手机固件的信息,比如说手机rom的版本等等,这些信息放在了android系统的system/build.prop文件里面。可以使用adb shell cat进行查看,如果要查看具体的每行的含义可以查看下面的网址:

http://blog.csdn.net/whatday/article/details/45332651


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值