美文网首页
Android aapt的使用

Android aapt的使用

作者: RookieRun | 来源:发表于2019-06-05 09:43 被阅读0次
    aapt list test.apk//查看apk文件内容
    

    AndroidManifest.xml
    META-INF/CERT.RSA
    ...
    META-INF/proguard/androidx-annotations.pro
    classes.dex
    res/anim/abc_fade_in.xml
    ...
    res/mipmap-xxxhdpi-v4/ic_launcher_round.png
    resources.arsc

    结果,其实和AS查看apk的结果是相同的:


    Android Studio 查看apk
    aapt dump badging test.apk//查看Apk基础信息(包名,版本号,sdkVersion,以及权限列表等)
    

    package: name='com.example.plugintest_host' versionCode='1' versionName='1.0'
    sdkVersion:'16'
    targetSdkVersion:'28'
    uses-permission: name='android.permission.INTERNET'
    uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
    uses-permission: name='android.permission.CHANGE_NETWORK_STATE'
    uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
    uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
    uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
    ...
    application-debuggable
    launchable-activity: name='com.example.plugintest_host.MainActivity' label='' icon=''
    feature-group: label=''
    uses-feature: name='android.hardware.faketouch'
    uses-implied-feature: name='android.hardware.faketouch' reason='default feature for all apps'
    main
    other-activities
    other-services
    supports-screens: 'small' 'normal' 'large' 'xlarge'
    supports-any-density: 'true'
    locales: '--_--' 'af' 'am' 'ar' 'as' 'az' 'be' 'bg' 'bn' 'bs' 'ca' 'cs' 'da' 'de' 'el' 'en-AU' 'en-CA' 'en-GB' 'en-IN' 'en-XC' 'es' 'es-US' 'et' 'eu' 'fa' 'fi' 'fr' 'fr-CA' 'gl' 'gu' 'hi' 'hr' 'hu' 'hy' 'in' 'is' 'it' 'iw' 'ja' 'ka' 'kk' 'km' 'kn' 'ko' 'ky' 'lo' 'lt' 'lv' 'mk' 'ml' 'mn' 'mr' 'ms' 'my' 'nb' 'ne' 'nl' 'or' 'pa' 'pl' 'pt' 'pt-BR' 'pt-PT' 'ro' 'ru' 'si' 'sk' 'sl' 'sq' 'sr' 'sr-Latn' 'sv' 'sw' 'ta' 'te' 'th' 'tl' 'tr' 'uk' 'ur' 'uz' 'vi' 'zh-CN' 'zh-HK' 'zh-TW' 'zu'
    densities: '120' '160' '240' '320' '480' '640' '65534'

    3.当然也可以直接查看权限列表

    aapt dump permissions app-debug.apk
    

    package: com.example.plugintest_host
    uses-permission: name='android.permission.INTERNET'
    uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
    uses-permission: name='android.permission.CHANGE_NETWORK_STATE'
    uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
    uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
    uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
    4.其他aapt命令

    #获取 APK 的配置列表
    aapt dump configurations app-debug.apk
    
    # 打印出 APK 里的资源清单
    aapt dump resources app-debug.apk
    
    # 打印出指定 APK 里编译过的 xml
    aapt dump xmltree app-debug.apk
    
    # 打印出编译过的 xml 里的字段
    aapt dump xmlstrings app-debug.apk
    
    # 列出 ZIP 存档里的内容
    aapt list -v -a  app-debug.apk
    

    参考文章:
    1.https://juejin.im/entry/57f9de43a22b9d005bf7fab0?utm_source=gold-miner&utm_medium=readme&utm_campaign=github

    相关文章

      网友评论

          本文标题:Android aapt的使用

          本文链接:https://www.haomeiwen.com/subject/bycjxctx.html