前言
1、简介
aapt(Android Asset Packaging Tool)即Android资源打包工具,是一款运用于android SDK的反汇编工具,具有apk编译、反编译、分析等功能。
2、环境配置
aapt一般在AndroidSDK的build-tools目录下,把D:\AndroidSDK\build-tools\29.0.3
添加至path
环境变量中,我们就可以任意地方使用aapt命令。如:
命令行输入
aapt v
即可查看是否配置成功和版本号:image.png
3、工具使用
aapt l[ist] [-v] [-a] 文件名.{zip,jar,apk}
备注:
1. 测试apk保存于I盘中,请注意甄别。
2. 若出现ERROR: dump failed because no AndroidManifest.xml found
报错,原因是apk路径不能含中文!!!
-
示例1:
aapt l I:\com.youku.phone-10.1.5-461-1126.apk
简单的罗列压缩文件中每一项的内容: image.png -
示例2:
aapt l -v I:\com.youku.phone-10.1.5-461-1126.apk
列表方式详细标识出压缩文件中的每一项和很多参数: image.png 字段介绍:
Length:原始文件的长度
Date:日期
Time:时间
Name:名称
Method:压缩方法,Deflate及Stored两种,即该Zip目录采用的算法是压缩模式还是存储模式;可以看出resources.arsc、.png采用压缩模式,而其它采用压缩模式。
Ratio:压缩率
Size:这个是压缩省掉的大小,即如果压缩率是xx%。那Size是原始长度*(1-xx%)。
CRC-32:循环冗余校验。这个计算是有特定的算法的。
offset:zipfile中偏移量的意思 -
示例3:
aapt l -a I:\com.youku.phone-10.1.5-461-1126.apk
详细输出压缩文件中所有目录的内容 -
示例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:'优酷视频'
application-label-zh:'优酷视频'
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='优酷视频' icon='res/drawable-hdpi-v4/ic_launcher.png'
uses-library-not-required:'org.apache.http.legacy'
launchable-activity: name='com.youku.phone.ActivityWelcome' label='优酷视频' 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'
结语:由于工作需求是获取根据apk的获取应用的中文名和版本号,aapt拓展操作后续学习,参考文档:https://www.jianshu.com/p/8d691b6bf8b4
网友评论