Android aapt 在 Mac 上的使用

最近需要用到android sdk的aapt来解析apk包,这里我分享一下我的使用过程,首先配置aapt的环境变量:

AAPT_HOME=/Users/admin/Library/Android/sdk/build-tools/29.0.3
export AAPT_HOME
export PATH=$PATH:$AAPT_HOME

把这几行加入到~/.zshrc中去,然后测试,重新打开一个terminal:

(base) ➜  ~ aapt
Android Asset Packaging Tool

Usage:
 aapt l[ist] [-v] [-a] file.{zip,jar,apk}
   List contents of Zip-compatible archive.

 aapt d[ump] [--values] [--include-meta-data] 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.

说明添加成功,然后进行操作,这里以拼多多的apk为例:

(base) ➜  android aapt dump badging 拼多多官方.apk
package: name='com.xunmeng.pinduoduo' versionCode='51101' versionName='5.11.1' compileSdkVersion='29' compileSdkVersionCodename='10'
sdkVersion:'15'
targetSdkVersion:'27'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.READ_PHONE_STATE'
uses-permission: name='android.permission.READ_LOGS'
uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission: name='android.permission.CAMERA'
uses-permission: name='android.permission.FLASHLIGHT'
uses-permission: name='android.permission.READ_CONTACTS'
uses-permission: name='android.permission.RECORD_AUDIO'
uses-permission: name='android.permission.MODIFY_AUDIO_SETTINGS'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.GET_PACKAGE_SIZE'
uses-permission: name='android.permission.REQUEST_INSTALL_PACKAGES'
.....

参考文献

[1].Android aapt 在 Mac 和 Windows 上使用方法小结. https://www.jianshu.com/p/00b83e34f8bf

[2].Mac 配置AAPT环境变量. https://blog.csdn.net/sweetzhangxue/article/details/75557652

猜你喜欢

转载自blog.csdn.net/w5688414/article/details/105913907