shwenzhang / AndResGuard

proguard resource for Android by wechat team
Apache License 2.0
8.54k stars 1.54k forks source link

crash with slidingmenumain which reported by Chunlin Tang #75

Closed simpleton closed 8 years ago

simpleton commented 8 years ago
copy res file not in resources.arsc file:layout/slidingmenumain.xml
copy res file not in resources.arsc file:values/ids.xml
copy res file not in resources.arsc file:values/attrs.xml
writing new resources.arsc 
resources.arsc Character Encoding: utf-16
general unsigned apk: input_unsigned.apk
DestResDir 1522 rawResDir 1522
java.io.IOException: do not have the compress data path=r/layout/slidingmenumain.xml
    at com.tencent.mm.util.FileOperation.zipFile(FileOperation.java:226)
    at com.tencent.mm.util.FileOperation.zipFile(FileOperation.java:217)
    at com.tencent.mm.util.FileOperation.zipFile(FileOperation.java:217)
    at com.tencent.mm.util.FileOperation.zipFiles(FileOperation.java:206)
    at com.tencent.mm.androlib.ResourceApkBuilder.generalUnsignApk(ResourceApkBuilder.java:208)
    at com.tencent.mm.androlib.ResourceApkBuilder.buildApk(ResourceApkBuilder.java:45)
    at com.tencent.mm.resourceproguard.Main.buildApk(Main.java:94)
    at com.tencent.mm.resourceproguard.Main.resourceProguard(Main.java:71)
    at com.tencent.mm.resourceproguard.cli.CliMain.run(CliMain.java:193)
    at com.tencent.mm.resourceproguard.cli.CliMain.main(CliMain.java:37)

slidingmenumain.xml 是我应用的第三方库com.slidingmenu.lib。就是侧面滑动那个库。 我跟踪了 AndResGuard 源码,发现 resources.arsc 解析的是否,并没有解析到 res/layout/slidingmenumain.xml. 所以导致了最后compressData 数据中无slidingmenumain。 最后在下面语句中出现了错误:

if (rootpath.contains("\\")) {
    rootpath = rootpath.replace("\\", "/");
}
if (!compressData.containsKey(rootpath)) {
    throw new IOException(String.format("do not have the compress data path=%s", rootpath));
}
simpleton commented 8 years ago

我使用了给我的test.apk进行了混淆发现可以成功混淆。 但是ResDir的数量不一致,不知是否和你给的apk是否一致。

DestResDir 1470 rawResDir 1470
signing apk: input_signed.apk
zipaligning apk: input_signed.apk
resources proguard done, total time cost: 4.221000s
resources proguard done, you can go to file to find the output /Users/sun/github/AndResGuard/tool_output/outapk

另外我解压了你给我的apk,发现slidingmenumain.xml并未被打包进apk。

kevintcl commented 8 years ago

的确,我刚才也看了,那天给你的包中没有slidingmenumain.xml,我刚打了一个包发现里面是有slidingmenumain.xml,没搞懂。两个包都是签了名的。唯一区别就是那天给你的那个包,不是我自己打的。

simpleton commented 8 years ago

@kevintcl 在我的印象里 官方不推荐把资源放置在jar包中,应当是aar包。引发这个crash的原因是因为这个资源并没有被写入到resource.asrc中。我现在已经改了这个repo的代码,避免了crash的问题。

kevintcl commented 8 years ago

@simpleton slidingmenumain 是一个好几年前引入的库。谢谢了!

simpleton commented 8 years ago

@kevintcl 你晚些时候更新1.1.9可以fix这个问题

kevintcl commented 8 years ago

OK