高德解包和打包报错

解包和打包报错

解包报错

PS D:\code\amapauto-editor\resources> java -jar apktool.jar d gaode.apk -f
I: Using Apktool 2.12.1 on gaode.apk with 8 threads
I: Baksmaling classes.dex...
I: Loading resource table...
I: Decoding file-resources...
I: Loading resource table from file: C:\Users\Administrator\AppData\Local\apktool\framework\1.apk
S: Could not decode file, replacing by FALSE value: anim/abc_slide_in_bottom.xml
S: Could not decode file, replacing by FALSE value: anim/abc_fade_in.xml
S: Could not decode file, replacing by FALSE value: anim/abc_slide_in_top.xml
S: Could not decode file, replacing by FALSE value: anim/activity_enter.xml
S: Could not decode file, replacing by FALSE value: anim/activity_exit.xml
S: Could not decode file, replacing by FALSE value: anim/abc_slide_out_top.xml
S: Could not decode file, replacing by FALSE value: anim/abc_fade_out.xml
S: Could not decode file, replacing by FALSE value: anim/abc_slide_out_bottom.xml
I: Decoding values */* XMLs...
I: Decoding AndroidManifest.xml with resources...
I: Copying original files...

打包报错

PS D:\code\amapauto-editor\resources> java -jar apktool.jar b gaode
I: Using Apktool 2.12.1 on gaode.apk with 8 threads
I: Checking whether sources have changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources have changed...
I: Building resources with aapt2...
W: D:\code\amapauto-editor\resources\gaode\res\values\anims.xml:3: error: invalid value for type 'anim'. Expected a reference.
W: D:\code\amapauto-editor\resources\gaode\res\values\anims.xml:4: error: invalid value for type 'anim'. Expected a reference.
W: D:\code\amapauto-editor\resources\gaode\res\values\anims.xml:5: error: invalid value for type 'anim'. Expected a reference.
W: D:\code\amapauto-editor\resources\gaode\res\values\anims.xml:6: error: invalid value for type 'anim'. Expected a reference.
W: D:\code\amapauto-editor\resources\gaode\res\values\anims.xml:7: error: invalid value for type 'anim'. Expected a reference.
W: D:\code\amapauto-editor\resources\gaode\res\values\anims.xml:8: error: invalid value for type 'anim'. Expected a reference.
W: D:\code\amapauto-editor\resources\gaode\res\values\anims.xml:9: error: invalid value for type 'anim'. Expected a reference.
W: D:\code\amapauto-editor\resources\gaode\res\values\anims.xml:10: error: invalid value for type 'anim'. Expected a reference.
W: D:\code\amapauto-editor\resources\gaode\res\values\anims.xml: error: file failed to compile.
Exception in thread "main" brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\ADMINI~1\AppData\Local\Temp\brut_util_Jar_49951423408581740395031504976716335730.tmp, compile, --dir, D:\code\amapauto-editor\resources\gaode\res, --legacy, -o, D:\code\amapauto-editor\resources\gaode\build\resources.zip]
        at brut.androlib.AaptInvoker.invoke(SourceFile:105)
        at brut.androlib.ApkBuilder.buildResources(SourceFile:328)
        at brut.apktool.Main.main(SourceFile:96)
Caused by: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\ADMINI~1\AppData\Local\Temp\brut_util_Jar_49951423408581740395031504976716335730.tmp, compile, --dir, D:\code\amapauto-editor\resources\gaode\res, --legacy, -o, D:\code\amapauto-editor\resources\gaode\build\resources.zip]
        at brut.util.OS.exec(SourceFile:148)
        at brut.androlib.AaptInvoker.invoke(SourceFile:101)
        ... 2 more

最终结论梳理

所以最后的出的结论是,apk解包的时候,apktool就会把apk打包所需的framework安装到本机上,比如windows在C:\Users\Administrator\AppData\Local\apktool\framework\1.apk。
所以不会存在版本不匹配问题!

编译出错,缺少资源是因为个别apk做了混淆或主动优化等导致,大部分的解包打包工具,都会内置对这些部分apk打包前的资源处理

Framework管理

  • 自动安装:Apktool在解包时自动安装所需framework到 C:\Users\Administrator\AppData\Local\apktool\framework\1.apk
  • 版本匹配:不会出现framework版本不匹配问题
  • 缓存重用:同版本APK共用已安装的framework

资源问题的本质

  • 不是Apktool的bug:而是APK自身的构建特性
  • 商业APK的常见策略
    • 资源混淆和优化
    • 动态资源加载
    • 多设备适配残留
    • 构建工具链差异

专业解包和打包工具的应对方案

// 商业化工具的内置修复逻辑
const builtInFixes = {
    '高德地图': () => fixAmapSpecificIssues(),
    '腾讯系APK': () => fixTencentResourceRefs(), 
    '阿里系APK': () => fixAliResourcePatterns(),
    '通用修复': () => fixCommonXmlErrors()
};

用户体验目标

  • 零配置:用户不需要懂framework、资源修复
  • 自动处理:工具内置各种常见APK的修复规则
  • 透明操作:在后台静默处理,只给用户成功/失败的结果

这就是为什么像APK Easy Tool、MT Manager这类工具能够"一键解包打包"的原因,它们都在底层内置了这些修复逻辑!

现在你可以 confidently 告诉用户:"这是正常现象,我们的工具会自动处理"。

posted @ 2025-09-30 12:43  丁少华  阅读(30)  评论(0)    收藏  举报