【Android】玩转命令行工具-aapt2
16lz
2021-01-26
aapt2即Android Asset Packaging Tool,是Android中的资源打包工具,另外还有个过时的aapt。aapt2是Android API 26.0.2才出现的,在Android SDK中的位置为android_sdk/build-tools/version/aapt2
。
aapt2编译资源分为两步,第一步编译,分别编译每个资源为一个独立的二进制文件,文件后缀为.flat
;第二步链接,合并上一步编译出来的所有的二进制文件为一个文件,这也是支持增量编译的基础。
aapt2的编译和链接让AndroidStudio或者Android.mk执行就好了,对于一个apk来说,aapt2还可以dump其中的资源信息,如下例子所示。
$ ./build-tools/28.0.3/aapt2 dump Animal.apk Binary APKPackage name=a.b.animal id=7f type color id=05 entryCount=1 resource 0x7f050000 color/color_default () #ff0000ff type drawable id=02 entryCount=4 resource 0x7f020000 drawable/animal () (file) res/drawable/animal.jpg resource 0x7f020001 drawable/ic_launcher_background () (file) res/drawable/ic_launcher_background.xml type=XML resource 0x7f020002 drawable/ic_launcher_foreground (v24) (file) res/drawable-v24/ic_launcher_foreground.xml type=XML resource 0x7f020003 drawable/ic_launcher_foreground_1 (v24) (file) res/drawable-v24/ic_launcher_foreground_1.xml type=XML type id id=08 entryCount=4 resource 0x7f080000 id/image_animal () (id) resource 0x7f080001 id/theme_default () (id) resource 0x7f080002 id/theme_dog () (id) resource 0x7f080003 id/theme_monkey () (id) type layout id=04 entryCount=1 resource 0x7f040000 layout/layout_main () (file) res/layout/layout_main.xml type=XML type mipmap id=03 entryCount=2 resource 0x7f030000 mipmap/ic_launcher (mdpi-v4) (file) res/mipmap-mdpi-v4/ic_launcher.png type=PNG (hdpi-v4) (file) res/mipmap-hdpi-v4/ic_launcher.png type=PNG (xhdpi-v4) (file) res/mipmap-xhdpi-v4/ic_launcher.png type=PNG (xxhdpi-v4) (file) res/mipmap-xxhdpi-v4/ic_launcher.png type=PNG (xxxhdpi-v4) (file) res/mipmap-xxxhdpi-v4/ic_launcher.png type=PNG (anydpi-v26) (file) res/mipmap-anydpi-v26/ic_launcher.xml type=XML resource 0x7f030001 mipmap/ic_launcher_round (mdpi-v4) (file) res/mipmap-mdpi-v4/ic_launcher_round.png type=PNG (hdpi-v4) (file) res/mipmap-hdpi-v4/ic_launcher_round.png type=PNG (xhdpi-v4) (file) res/mipmap-xhdpi-v4/ic_launcher_round.png type=PNG (xxhdpi-v4) (file) res/mipmap-xxhdpi-v4/ic_launcher_round.png type=PNG (xxxhdpi-v4) (file) res/mipmap-xxxhdpi-v4/ic_launcher_round.png type=PNG (anydpi-v26) (file) res/mipmap-anydpi-v26/ic_launcher_round.xml type=XML type string id=06 entryCount=4 resource 0x7f060000 string/app_name () "Animal" (en-rXA) "[Åñîḿåļ one two]" (ar-rXB) "Animal" resource 0x7f060001 string/theme_default () "Default" (en-rXA) "[Ðéƒåûļţ one two]" (ar-rXB) "Default" resource 0x7f060002 string/theme_dog () "Dog" (en-rXA) "[Ðöĝ one]" (ar-rXB) "Dog" resource 0x7f060003 string/theme_monkey () "Monkey" (en-rXA) "[Ḿöñķéý one two]" (ar-rXB) "Monkey" type style id=07 entryCount=1 resource 0x7f070000 style/AppTheme () (style) size=0 parent=0x01030060
参考:https://developer.android.com/studio/command-line/aapt2
更多相关文章
- c/c++ android 平台交叉编译 {ERROR: Failed to create toolchai
- Ubuntu下为AndroidStudio编译并使用x264(二)AndroidStudio部分
- ubutun下NDK编译环境配置
- Android(安卓)编译错误总结及收集
- Android(安卓)Studio修改项目编译版本
- android ffmpeg4.0.2编译过程记录
- Android(安卓)CPU, Compilers, D8 & R8
- Android多窗口的实现 - 开源
- 简单的Android之apk包反编译方法