zoukankan      html  css  js  c++  java
  • [Android]aapt使用小结

    aapt命令小结 


    aapt即Android Asset Packaging Tool.本文小结了一下该工具的用法。


    1.  aapt l[ist] [-v] [-a] file.{zip,jar,apk}
       List contents of Zip-compatible archive.
    1.1 列出压缩文件目录
    aapt l <file_path.apk>
    参数:
    -v:会以table的形式输出目录,table的表目有:Length、Method、Size、Ratio、Date、Time、CRC-32、Name。
    其中Method表示压缩形式,有:Deflate及Stored两种,即该Zip目录采用的算法是压缩模式还是存储模式;可以看出resources.arsc、*.png采用压缩模式,而其它采用压缩模式。
    Ratio表示压缩率。CRC-32未明其意,Sodino盼指教。

    -a:会详细输出所有目录的内容。
    效果图:aapt_list.JPG
    list


    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等各种详细信息
    aapt dump badging <file_path.apk>
    效果图:aapt_dump_badging.JPG
    badging

    2.2 查看权限
    aapt dump permissions <file_path.apk>
    效果图:aapt_dump_permissions.JPG

    permission

    2.3 查看资源列表
    aapt dump resources <file_path.apk>
    一般都会输出很多的信息,如要全部查看,请用下面这两句:
    aapt dump resources <file_path.apk>   > sodino.txt
    sodino.txt
    这样会把所有的信息通过重定向符">"输出到sodino.txt文件中,然后再打开该文件即可查看。


    2.4 查看apk配置信息
    aapt dump configurations <file_path.apk>


    2.5 查看指定apk的指定xml文件。
    aapt dump xmltree <file_path.apk> res/***.xml
    以树形结构输出的xml信息。
    aapt dump xmlstrings <file_path.apk> res/***.xml
    输出xml文件中所有的字符串信息。
    效果图:aapt_dump_xmltree.JPG

    xmltree

    3
    由于此处代码量比较大,本人写成批处理形式了。

    使用aapt生成R.java
    rem 测试的工程目录下必须得有gen文件夹,否则会提示: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绝对路径。
    %ASSETS%:asset文件夹路径。
    %RESOURCE%:生成的resouces.arsc存放路径。

    参考:
    Android系列之Android 命令行手动编译打包详解
    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   

    r_a_v

    本文内容归CSDN博客博主Sodino 所有
    转载请注明出处:http://blog.csdn.net/sodino/archive/2011/01/07/6122665.aspx

  • 相关阅读:
    刘汝佳,竖式问题
    二叉树
    sort
    hash
    贪心算法
    FFT,NTT 专题
    hdu 5861 Road 两棵线段树
    hdu 5862 Counting Intersections
    hdu 5833 Zhu and 772002 ccpc网络赛 高斯消元法
    hdu 5800 To My Girlfriend + dp
  • 原文地址:https://www.cnblogs.com/bydzhangxiaowei/p/8172766.html
Copyright © 2011-2022 走看看