最近需要用到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.
(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'
.....