appt使用小结
aapt命令小結(jié)
aapt即Android Asset Packaging Tool.本文小結(jié)了一下該工具的用法。
1. aapt l[ist] [-v] [-a] file.{zip,jar,apk}
List contents of Zip-compatible archive.
1.1 列出壓縮文件目錄
aapt l <file_path.apk>
參數(shù):
-v:會(huì)以table的形式輸出目錄,table的表目有:Length、Method、Size、Ratio、Date、Time、CRC-32、Name。
其中Method表示壓縮形式,有:Deflate及Stored兩種,即該Zip目錄采用的算法是壓縮模式還是存儲(chǔ)模式;可以看出resources.arsc、*.png采用壓縮模式,而其它采用壓縮模式。
Ratio表示壓縮率。CRC-32未明其意,Sodino盼指教。
-a:會(huì)詳細(xì)輸出所有目錄的內(nèi)容。
效果圖:aapt_list.JPG
2. 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.
2.1 查看apk包的packageName、versionCode、applicationLabel、launcherActivity、permission等各種詳細(xì)信息
aapt dump badging <file_path.apk>
效果圖:aapt_dump_badging.JPG
2.2 查看權(quán)限
aapt dump permissions <file_path.apk>
效果圖:aapt_dump_permissions.JPG
2.3 查看資源列表
aapt dump resources <file_path.apk>
一般都會(huì)輸出很多的信息,如要全部查看,請(qǐng)用下面這兩句:
aapt dump resources <file_path.apk> > sodino.txt
sodino.txt
這樣會(huì)把所有的信息通過重定向符">"輸出到sodino.txt文件中,然后再打開該文件即可查看。
2.4 查看apk配置信息
aapt dump configurations <file_path.apk>
2.5 查看指定apk的指定xml文件。
aapt dump xmltree <file_path.apk> res/***.xml
以樹形結(jié)構(gòu)輸出的xml信息。
aapt dump xmlstrings <file_path.apk> res/***.xml
輸出xml文件中所有的字符串信息。
效果圖:aapt_dump_xmltree.JPG
3
由于此處代碼量比較大,本人寫成批處理形式了。
使用aapt生成R.java
rem 測(cè)試的工程目錄下必須得有g(shù)en文件夾,否則會(huì)提示:Unable to open class file R.java:No such file or directory
%aapt% package -f -m -J %GEN% -S %RES% -I %ANDROID_JAR% -M %ANDROID_MANIFEST_XML%
使用aapt生成資源包文件
%aapt% package -f -M %ANDROID_MANIFEST_XML% -S %RES% -A %ASSETS% -I %ANDROID_JAR% -F %RESOURCE%
%GEN%:存放的R.java文件夾路徑。
%RES%:res文件夾路徑。
%ANDROID_JAR%:引用的android.jar路徑。
%ANDROID_MANIFEST_XML%:工程AndroidManifest.xml絕對(duì)路徑。
%ASSETS%:asset文件夾路徑。
%RESOURCE%:生成的resouces.arsc存放路徑。
參考:
Android系列之Android 命令行手動(dòng)編譯打包詳解
http://blog168.chinaunix.net/space.php?uid=22957718&do=blog&cuid=2322671
其余的不解釋,直接見效果圖:
aapt r[emove] [-v] file.{zip,jar,apk} file1 [file2 ...]
Delete specified files from Zip-compatible archive.
aapt a[dd] [-v] file.{zip,jar,apk} file1 [file2 ...]
Add specified files to Zip-compatible archive.
aapt v[ersion]
Print program version.
效果圖:aapt_r_a_v.JPG
本文內(nèi)容歸CSDN博客博主Sodino 所有
轉(zhuǎn)載請(qǐng)注明出處:http://blog.csdn.net/sodino/archive/2011/01/07/6122665.aspx
總結(jié)
- 上一篇: (stm32f103学习总结)—stm3
- 下一篇: 什么是UUId?理解UUId的五个版本和