一、前言
bundletool是一个强大的aar包工具,可以对aar包生成apks集合,检测基础apk包大小等等,可参考:bundletool工具使用详解 一文。在本章节,将详细介绍一下如何使用bundletool工具,从aar中获取各种包信息。
二、使用 dump 命令获取aar包各种信息
2.1 关于 dump 命令
可以使用 bundletool help dump 查看bundletool工具的 dump 命令的详细介绍,其中包含样例、信息来源分类以及命令选项,如下所示:
Description:
Prints files or extract values from the bundle in a human-readable form.
Examples:
1. Prints the AndroidManifest.xml of the base module:
$ bundletool dump manifest --bundle=/tmp/app.aab
2. Prints the versionCode of the bundle of the base module:
$ bundletool dump manifest --bundle=/tmp/app.aab --
xpath=/manifest/@versionCode
3. Prints all the resources present in the bundle:
$ bundletool dump resources --bundle=/tmp/app.aab
4. Prints a resource's configs from its resource ID:
$ bundletool dump resources --bundle=/tmp/app.aab --resource=0x7f0e013a
5. Prints a resource's configs and values from its resource type & name:
$ bundletool dump resources --bundle=/tmp/app.aab --resource=drawable/icon
--values
6. Prints the content of the bundle configuration file:
$ bundletool dump config --bundle=/tmp/app.aab
7. Prints the content of the runtime-enabled SDK configuration file:
$ bundletool dump runtime-enabled-sdk-config --bundle=/tmp/app.aab
Synopsis:
bundletool dump <manifest|resources|config|runtime-enabled-sdk-config>
--bundle=<app.aab>
[--module=<base>]
[--resource=<0x7f030001>]
[--values]
[--xpath=</manifest/@android:versionCode>]
Flags:
--bundle: Path to the Android App Bundle.
--module: (Optional) Name of the module to apply the dump for. Only applies
when dumping the manifest. Defaults to 'base'.
--resource: (Optional) Name or ID of the resource to lookup. Only applies
when dumping resources. If a resource ID is provided, it can be
specified either as a decimal or hexadecimal integer. If a resource name
is provided, it must follow the format '<type>/<name>', e.g.
'drawable/icon'
--values: (Optional) When set, also prints the values of the resources.
Defaults to false. Only applies when dumping the resources.
--xpath: (Optional) XPath expression to extract the value of attributes from
the XML file being dumped. Only applies when dumping the manifest.

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



