前言
1伸头、簡介
aapt(Android Asset Packaging Tool)即Android資源打包工具妄帘,是一款運用于android SDK的反匯編工具妆毕,具有apk編譯趾诗、反編譯、分析等功能幸撕。
2薇组、環(huán)境配置
aapt一般在AndroidSDK的build-tools目錄下,把D:\AndroidSDK\build-tools\29.0.3
添加至path
環(huán)境變量中坐儿,我們就可以任意地方使用aapt命令律胀。如:
命令行輸入
aapt v
即可查看是否配置成功和版本號:3、工具使用
aapt l[ist] [-v] [-a] 文件名.{zip,jar,apk}
備注:
1. 測試apk保存于I盤中貌矿,請注意甄別炭菌。
2. 若出現(xiàn)ERROR: dump failed because no AndroidManifest.xml found
報錯,原因是apk路徑不能含中文9渎:诘汀!
-
示例1:
aapt l I:\com.youku.phone-10.1.5-461-1126.apk
簡單的羅列壓縮文件中每一項的內(nèi)容: -
示例2:
aapt l -v I:\com.youku.phone-10.1.5-461-1126.apk
列表方式詳細(xì)標(biāo)識出壓縮文件中的每一項和很多參數(shù):
Length:原始文件的長度
Date:日期
Time:時間
Name:名稱
Method:壓縮方法,Deflate及Stored兩種克握,即該Zip目錄采用的算法是壓縮模式還是存儲模式蕾管;可以看出resources.arsc、.png采用壓縮模式菩暗,而其它采用壓縮模式掰曾。
Ratio:壓縮率
Size:這個是壓縮省掉的大小,即如果壓縮率是xx%停团。那Size是原始長度*(1-xx%)旷坦。
CRC-32:循環(huán)冗余校驗。這個計算是有特定的算法的客蹋。
offset:zipfile中偏移量的意思 -
示例3:
aapt l -a I:\com.youku.phone-10.1.5-461-1126.apk
詳細(xì)輸出壓縮文件中所有目錄的內(nèi)容 -
示例4:
aapt dump strings I:\com.youku.phone-10.1.5-461-1126.apk
打印apk中所有string資源表 -
示例5:
aapt dump badging I:\com.youku.phone-10.1.5-461-1126.apk
查看apk中的配置信息
示例5打印信息:
package: name='com.youku.phone' versionCode='461' versionName='10.1.5' compileSdkVersion='29' compileSdkVersionCodename='10'
install-location:'auto'
sdkVersion:'21'
targetSdkVersion:'29'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.GET_TASKS'
uses-permission: name='android.permission.CHANGE_NETWORK_STATE'
uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
uses-permission: name='android.permission.BLUETOOTH'
uses-permission: name='android.permission.CHANGE_WIFI_STATE'
uses-permission: name='android.permission.READ_PHONE_STATE'
uses-permission: name='android.permission.CAMERA'
uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission: name='android.permission.RECORD_AUDIO'
uses-permission: name='android.permission.ACCESS_COARSE_LOCATION'
uses-permission: name='android.permission.ACCESS_FINE_LOCATION'
uses-permission: name='android.permission.MOUNT_UNMOUNT_FILESYSTEMS'
uses-permission: name='com.android.launcher.permission.INSTALL_SHORTCUT'
uses-permission: name='android.permission.REQUEST_INSTALL_PACKAGES'
uses-permission: name='android.permission.NFC'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission: name='com.huawei.permission.ACCESS_DISPLAY_ENGINE'
uses-permission: name='android.permission.READ_CALENDAR'
uses-permission: name='android.permission.USE_FINGERPRINT'
uses-permission: name='android.permission.DOWNLOAD_WITHOUT_NOTIFICATION'
uses-permission: name='android.permission.AUTHENTICATE_ACCOUNTS' maxSdkVersion='22'
uses-permission: name='android.permission.WRITE_SYNC_SETTINGS'
uses-permission: name='android.permission.ACCESS_LOCATION_EXTRA_COMMANDS'
uses-permission: name='com.sec.android.provider.badge.permission.READ'
uses-permission: name='com.sec.android.provider.badge.permission.WRITE'
uses-permission: name='com.htc.launcher.permission.READ_SETTINGS'
uses-permission: name='com.htc.launcher.permission.UPDATE_SHORTCUT'
uses-permission: name='com.sonyericsson.home.permission.BROADCAST_BADGE'
uses-permission: name='com.sonymobile.home.permission.PROVIDER_INSERT_BADGE'
uses-permission: name='com.huawei.android.launcher.permission.CHANGE_BADGE'
uses-permission: name='com.huawei.android.launcher.permission.READ_SETTINGS'
uses-permission: name='com.huawei.android.launcher.permission.WRITE_SETTINGS'
uses-permission: name='com.oppo.launcher.permission.READ_SETTINGS'
uses-permission: name='com.oppo.launcher.permission.WRITE_SETTINGS'
uses-permission: name='com.vivo.notification.permission.BADGE_ICON'
uses-permission: name='android.permission.WRITE_CALENDAR'
uses-permission: name='com.youku.phone.permission.C2D_MESSAGE'
uses-permission: name='android.permission.SYSTEM_ALERT_WINDOW'
uses-permission: name='android.permission.READ_LOGS'
uses-permission: name='com.huawei.permission.ONEHOP'
uses-permission: name='android.permission.RUN_INSTRUMENTATION'
uses-permission: name='com.youku.phone.permission.MIPUSH_RECEIVE'
uses-permission: name='com.meizu.flyme.push.permission.RECEIVE'
uses-permission: name='com.youku.phone.push.permission.MESSAGE'
uses-permission: name='com.meizu.c2dm.permission.RECEIVE'
uses-permission: name='com.coloros.mcs.permission.RECIEVE_MCS_MESSAGE'
uses-permission: name='android.permission.BROADCAST_STICKY'
uses-permission: name='com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA'
uses-permission: name='android.permission.MODIFY_AUDIO_SETTINGS'
uses-permission: name='android.permission.CHANGE_WIFI_MULTICAST_STATE'
uses-permission: name='android.permission.ACCESS_MEDIA_LOCATION'
uses-permission: name='android.permission.READ_CONTACTS'
application-label:'優(yōu)酷視頻'
application-label-zh:'優(yōu)酷視頻'
application-icon-120:'res/drawable-hdpi-v4/ic_launcher.png'
application-icon-160:'res/drawable-hdpi-v4/ic_launcher.png'
application-icon-240:'res/drawable-hdpi-v4/ic_launcher.png'
application-icon-320:'res/drawable-xhdpi-v4/ic_launcher.png'
application-icon-480:'res/drawable-xxhdpi-v4/ic_launcher.png'
application-icon-640:'res/drawable-xxxhdpi-v4/ic_launcher.png'
application-icon-65534:'res/drawable-hdpi-v4/ic_launcher.png'
application-icon-65535:'res/drawable-xxxhdpi-v4/ic_launcher.png'
application: label='優(yōu)酷視頻' icon='res/drawable-hdpi-v4/ic_launcher.png'
uses-library-not-required:'org.apache.http.legacy'
launchable-activity: name='com.youku.phone.ActivityWelcome' label='優(yōu)酷視頻' icon=''
uses-library-not-required:'com.oppo.hyberboost.unit.sdk'
uses-library-not-required:'com.huawei.multimedia.hivideoplayengine'
uses-library:'android.test.runner'
feature-group: label=''
uses-gl-es: '0x20000'
uses-feature-not-required: name='android.hardware.camera'
uses-feature-not-required: name='android.hardware.camera.autofocus'
uses-feature-not-required: name='android.hardware.nfc'
uses-feature-not-required: name='android.hardware.sensor.stepcounter'
uses-feature: name='android.hardware.bluetooth'
uses-implied-feature: name='android.hardware.bluetooth' reason='requested android.permission.BLUETOOTH permission, and targetSdkVersion > 4'
uses-feature: name='android.hardware.faketouch'
uses-implied-feature: name='android.hardware.faketouch' reason='default feature for all apps'
uses-feature: name='android.hardware.location'
uses-implied-feature: name='android.hardware.location' reason='requested android.permission.ACCESS_COARSE_LOCATION permission, requested android.permission.ACCESS_FINE_LOCATION permission, and requested android.permission.ACCESS_LOCATION_EXTRA_COMMANDS permission'
uses-feature: name='android.hardware.microphone'
uses-implied-feature: name='android.hardware.microphone' reason='requested android.permission.RECORD_AUDIO permission'
uses-feature: name='android.hardware.screen.landscape'
uses-implied-feature: name='android.hardware.screen.landscape' reason='one or more activities have specified a landscape orientation'
uses-feature: name='android.hardware.screen.portrait'
uses-implied-feature: name='android.hardware.screen.portrait' reason='one or more activities have specified a portrait orientation'
uses-feature: name='android.hardware.wifi'
uses-implied-feature: name='android.hardware.wifi' reason='requested android.permission.ACCESS_WIFI_STATE permission, requested android.permission.CHANGE_WIFI_MULTICAST_STATE permission, and requested android.permission.CHANGE_WIFI_STATE permission'
provides-component:'search'
main
other-activities
other-receivers
other-services
supports-screens: 'small' 'normal' 'large' 'xlarge'
supports-any-density: 'true'
locales: '--_--' 'zh'
densities: '120' '160' '240' '320' '480' '640' '65534' '65535'
native-code: 'armeabi'
結(jié)語:由于工作需求是獲取根據(jù)apk的獲取應(yīng)用的中文名和版本號塞蹭,aapt拓展操作后續(xù)學(xué)習(xí)孽江,參考文檔:http://www.reibang.com/p/8d691b6bf8b4