aapt工具簡介及使用

前言

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命令律胀。如:

image.png

命令行輸入aapt v即可查看是否配置成功和版本號:
image.png

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渎:诘汀!

  • 示例1aapt l I:\com.youku.phone-10.1.5-461-1126.apk 簡單的羅列壓縮文件中每一項的內(nèi)容:
    image.png
  • 示例2aapt l -v I:\com.youku.phone-10.1.5-461-1126.apk 列表方式詳細(xì)標(biāo)識出壓縮文件中的每一項和很多參數(shù):
    image.png
    字段介紹:
    Length:原始文件的長度
    Date:日期
    Time:時間
    Name:名稱
    Method:壓縮方法,Deflate及Stored兩種克握,即該Zip目錄采用的算法是壓縮模式還是存儲模式蕾管;可以看出resources.arsc、.png采用壓縮模式菩暗,而其它采用壓縮模式掰曾。
    Ratio:壓縮率
    Size:這個是壓縮省掉的大小,即如果壓縮率是xx%停团。那Size是原始長度*(1-xx%)旷坦。
    CRC-32:循環(huán)冗余校驗。這個計算是有特定的算法的客蹋。
    offset:zipfile中偏移量的意思
  • 示例3aapt l -a I:\com.youku.phone-10.1.5-461-1126.apk 詳細(xì)輸出壓縮文件中所有目錄的內(nèi)容
  • 示例4aapt dump strings I:\com.youku.phone-10.1.5-461-1126.apk 打印apk中所有string資源表
  • 示例5aapt 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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末讶坯,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子岗屏,更是在濱河造成了極大的恐慌辆琅,老刑警劉巖,帶你破解...
    沈念sama閱讀 212,080評論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件这刷,死亡現(xiàn)場離奇詭異婉烟,居然都是意外死亡,警方通過查閱死者的電腦和手機暇屋,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,422評論 3 385
  • 文/潘曉璐 我一進(jìn)店門似袁,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人咐刨,你說我怎么就攤上這事昙衅。” “怎么了定鸟?”我有些...
    開封第一講書人閱讀 157,630評論 0 348
  • 文/不壞的土叔 我叫張陵而涉,是天一觀的道長。 經(jīng)常有香客問我联予,道長啼县,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,554評論 1 284
  • 正文 為了忘掉前任沸久,我火速辦了婚禮季眷,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘卷胯。我一直安慰自己子刮,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 65,662評論 6 386
  • 文/花漫 我一把揭開白布诵竭。 她就那樣靜靜地躺著话告,像睡著了一般兼搏。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上沙郭,一...
    開封第一講書人閱讀 49,856評論 1 290
  • 那天佛呻,我揣著相機與錄音,去河邊找鬼病线。 笑死吓著,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的送挑。 我是一名探鬼主播绑莺,決...
    沈念sama閱讀 39,014評論 3 408
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼惕耕!你這毒婦竟也來了纺裁?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,752評論 0 268
  • 序言:老撾萬榮一對情侶失蹤司澎,失蹤者是張志新(化名)和其女友劉穎欺缘,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體挤安,經(jīng)...
    沈念sama閱讀 44,212評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡谚殊,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,541評論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了蛤铜。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片嫩絮。...
    茶點故事閱讀 38,687評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖围肥,靈堂內(nèi)的尸體忽然破棺而出剿干,到底是詐尸還是另有隱情,我是刑警寧澤虐先,帶...
    沈念sama閱讀 34,347評論 4 331
  • 正文 年R本政府宣布怨愤,位于F島的核電站,受9級特大地震影響蛹批,放射性物質(zhì)發(fā)生泄漏撰洗。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,973評論 3 315
  • 文/蒙蒙 一腐芍、第九天 我趴在偏房一處隱蔽的房頂上張望差导。 院中可真熱鬧,春花似錦猪勇、人聲如沸设褐。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,777評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽助析。三九已至犀被,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間外冀,已是汗流浹背寡键。 一陣腳步聲響...
    開封第一講書人閱讀 32,006評論 1 266
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留雪隧,地道東北人西轩。 一個月前我還...
    沈念sama閱讀 46,406評論 2 360
  • 正文 我出身青樓,卻偏偏與公主長得像脑沿,于是被迫代替她去往敵國和親藕畔。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 43,576評論 2 349

推薦閱讀更多精彩內(nèi)容