App测试 | aapt解析apk常用命令

2018-09-05  本文已影响28人  Root_123

aapt常用命令

1. 列出apk包的内容

例如: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 dump badging D:\test\xxx.apk(APK的全名,如手机淘宝.apk) //获取apk包名和launcherActivity
aapt d permissions

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] …]

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

例如:
将工程的资源编译R.java文件
aapt package -m -J

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文件中

上一篇 下一篇

猜你喜欢

热点阅读