«

Android aapt介绍

时间:2024-3-2 17:18     作者:韩俊     分类: Android


什么是AAPT?
进入android-sdk-windowsplatform-tools目录,输入aapt,可以查看这个工具的具体描述:

Android Asset Packaging Tool

Usage:
aapt l[ist] [-v] [-a] file.{zip,jar,apk}
List contents of Zip-compatible archive.
例子:aapt l -a test.apk 可以打印出来这个apk的详细信息,包括apk里面res目录下的所有资源,AndroidManifest.xml文件详细信息等。如果只想看到AndroidManifest.xml文件里面的信息,可以使用下面的命令:aapt d badging test.apk。不用使用apktool反编译了。

aapt d[ump] [–values] WHAT file.{apk} [asset [asset …]]
strings Print the contents of the resource table string pool in the APK.
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 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,…]
[-c CONFIGS] [–preferred-configurations CONFIGS]
[raw-files-dir [raw-files-dir] …]
[–output-text-symbols DIR]

Package the android resources. It will read assets and resources that are
supplied with the -M -A -S or raw-files-dir arguments. The -J -P -F and -R
options control which files are output.

使用Ant编译apk的时候,使用aapt进行打包,脚本代码如下:

<target name="generate">
        <echo>Generate R.java from resource ...</echo>
        <exec executable="${aapt}" failonerror="true">
            <arg value="package" />
            <arg value="-m" />
            <arg value="-J" />
            <arg value="${gen}" />
            <arg value="-M" />
            <arg value="${AndroidManifest}" />
            <arg value="-S" />
            <arg value="${res}" />
            <arg value="-I" />
            <arg value="${androidjar}" />
        </exec>
    </target>

aapt r[emove] [-v] file.{zip,jar,apk} file1 [file2 …]
Delete specified files from Zip-compatible archive.
从一个apk中删除指定的文件

aapt a[dd] [-v] file.{zip,jar,apk} file1 [file2 …]
Add specified files to Zip-compatible archive.
将一个文件打包到apk里面

aapt c[runch] [-v] -S resource-sources … -C output-folder …
Do PNG preprocessing on one or several resource folders
and store the results in the output folder.

aapt s[ingleCrunch] [-v] -i input-file -o outputfile
Do PNG preprocessing on a single file.

aapt v[ersion]
Print program version.

标签: android

热门推荐