Android逆向开发apktool.yml详解,常用的doNotCompress、sdkInfo、unknownFiles、versionInfo修改需求说明

.yml文件简介

  • YML文件格式是YAML (YAML Aint Markup Language)编写的文件格式,YAML是一种直观的能够被电脑识别的的数据数据序列化格式,并且容易被人类阅读, 容易和脚本语言交互的,可以被支持YAML库的不同的编程语言程序导入,比如: C/C++, Ruby, Python, Java, Perl, C#, PHP等。YML文件是以数据为核心的,比传统的xml方式更加简洁。 YML文件的扩展名可以使用.yml或者.yaml

apktool.yml文件详解

  • 从名字就可以看出apktool.yml与apktool工具有关系,当我们使用apktool d fire.apk 命令来反编译一个apk,将会生成这个文件
  • 下面我们打开这个文件看看,并对里面的属性做个总结
    !!brut.androlib.meta.MetaInfo
    apkFileName: fire.apk
    compressionType: false
    doNotCompress:
    - resources.arsc
    - png
    - META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version
    - META-INF/androidx.lifecycle_lifecycle-livedata-core.version
    - META-INF/androidx.swiperefreshlayout_swiperefreshlayout.version
    - META-INF/androidx.cursoradapter_cursoradapter.version
    - META-INF/androidx.drawerlayout_drawerlayout.version
    - META-INF/androidx.print_print.version
    - META-INF/androidx.versionedparcelable_versionedparcelable.version
    - META-INF/androidx.interpolator_interpolator.version
    - META-INF/androidx.fragment_fragment.version
    - META-INF/androidx.customview_customview.version
    - META-INF/androidx.documentfile_documentfile.version
    - META-INF/androidx.legacy_legacy-support-core-utils.version
    - META-INF/androidx.loader_loader.version
    - META-INF/androidx.lifecycle_lifecycle-livedata.version
    - META-INF/androidx.lifecycle_lifecycle-runtime.version
    - META-INF/androidx.viewpager_viewpager.version
    - META-INF/androidx.asynclayoutinflater_asynclayoutinflater.version
    - META-INF/androidx.lifecycle_lifecycle-viewmodel.version
    - META-INF/androidx.core_core.version
    - META-INF/androidx.arch.core_core-runtime.version
    - META-INF/androidx.slidingpanelayout_slidingpanelayout.version
    - META-INF/androidx.coordinatorlayout_coordinatorlayout.version
    - META-INF/androidx.legacy_legacy-support-core-ui.version
    isFrameworkApk: false
    packageInfo:
      forcedPackageId: '127'
      renameManifestPackage: null
    sdkInfo:
      minSdkVersion: '26'
      targetSdkVersion: '28'
    sharedLibrary: false
    sparseResources: false
    unknownFiles:
      play-services-ads-identifier.properties: '8'
      play-services-tasks.properties: '8'
      firebase-components.properties: '8'
      play-services-measurement-api.properties: '8'
      play-services-measurement-base.properties: '8'
      firebase-analytics.properties: '8'
      play-services-measurement-impl.properties: '8'
      play-services-measurement.properties: '8'
      firebase-annotations.properties: '8'
      play-services-measurement-sdk-api.properties: '8'
      play-services-basement.properties: '8'
      firebase-measurement-connector.properties: '8'
      firebase-common.properties: '8'
      firebase-installations.properties: '8'
      play-services-stats.properties: '8'
      play-services-measurement-sdk.properties: '8'
      firebase-installations-interop.properties: '8'
    usesFramework:
      ids:
      - 1
      tag: null
    version: 2.4.1
    versionInfo:
      versionCode: '1'
      versionName: null
    
    属性说明
    apkFileName进行反编译操作的apk文件名
    compressionType用于确定 resources.arsc 对原始 apk 的压缩,以便在 [b]uild 期间进行复制
    doNotCompress不压缩的文件列表
    isFrameworkApk是否为Framework类型Apk
    packageInfo用于帮助支持 Android 4.2 重命名清单功能。自动检测资源和清单之间的差异并在 [b]uild 上执行自动 --rename-manifest-package
    sdkInfo用于重新填充 AndroidManifest.xml 中的 sdk 信息,当我们需要修改apk的最低版本号或者目标版本号时,可以修改minSdkVersion和targetSdkVersion的值,如果直接修改 AndroidManifest.xml则在回编译后不会起作用
    sharedLibrary用于通过自动检测共享库并在 [b]uild 上使用 --shared-lib 来帮助支持 Android 5 共享库功能
    sparseResourcesres资的源配置,默认false
    unknownFiles用于记录 apk 中非标准文件的名称位置,以便正确放置在重建的 apk 上
    usesFramework使用Framework,默认使用apktool提供的1.apk,也可以使用自己指定用哪个framework.apk
    version使用apktool进行反编译的版本号
    versionInfoapk的版本信息,可以修改versionCode和versionName来升级或降级当前apk的版本号或者版本名称

    在apktool官网找到的对apktool.yml这个文件的解释:

  • apktool.yml collects more information than last version
    • SdkInfo - Used to repopulate the sdk information in AndroidManifest.xml since newer aapt requires version information to be passed via parameter
    • packageInfo - Used to help support Android 4.2 renamed manifest feature. Automatically detects differences between resource and manifest and performs automatic --rename-manifest-package on [b]uild
    • versionInfo - Used to repopulate the version information in AndroidManifest.xml since newer aapt requires version information to be passed via parameter
    • compressionType - Used to determine the compression that resources.arsc had on the original apk in order to replicate during [b]uild
    • unknownFiles - Used to record name/location of non-standard files in an apk in order to place correctly on rebuilt apk
    • sharedLibrary - Used to help support Android 5 shared library feature by automatically detecting shared libraries and using --shared-lib on [b]uild
  • 如果是做渠道分包,我们经常会对apktool.yml这个文件进行改写的,比如游戏端改了某些东西,需要在各个渠道去发新包,又或者是接入的sdk版本升级,二次出包什么的,都会涉及到修改版本号(versionCode)和版本名称(versionName),我们只需要修改versionInfo里面的内容就可以了

  • 当我们再合并第三方的代码的时候,会经常遇到一些unknown文件的,这时候不仅需要把文件拷贝过来,还需要在unknownFiles中加入配置,配置就是在unknown文件夹中的相对路径,并加上": '8'"或者": '0'",如果不知道配置0或者8,最好是建一个空工程,引入第三方依赖包,生成一个apk,再使用apktool命令反编译出来,看里面unknown的配置,并合并过来,可以参考这篇文章Android逆向开发处理unknown文件&AppsFlyer库中classes.jar中的a-,b-资源合并问题_林慈桥的博客-CSDN博客
  • 如果我们的res、assets等目录下包含一些视频、音频、图片等文件,又不需要进行压缩,那么就需要配置doNotCompress了,特别是当我们合并第三方SDK的代码的时候,如果遇到某些视频、音频、大图片文件打不开,播放不了的时候,多半就是我们合并的资源被压缩了,导致找不到或者解析失败对应资源文件
  • 如果你的apk是framework的话,isFrameworkApk解析出来应该是true,一般的apk就是false
  • 如果你开发的apk用到了特定厂商的framework.apk,需要指定特定的framework,那么就需要修改usesFramework了

对apktool.yml进行解析和修改

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值