shwenzhang / AndResGuard

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

java.io.IOException: Crash when open keepmapping with an empty mapping file #72

Closed eurstein closed 8 years ago

eurstein commented 8 years ago

Config:

<issue id="keepmapping" isactive="true">
     <path value="mapping.txt"/> <!-- mapping.txt exists, but it's empty -->
</issue>

=> Crash:

_java.io.IOException: the file count of ...\res_out\temp\res, and the file count of ...\resout\res is not equal, there must be some problem at com.tencent.mm.androlib.ResourceApkBuilder.generalUnsignApk(ResourceApkBuilder.java:192) 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)

My Solution:

diff --git a/AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java b/AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java
index 31f1360..c440aa3 100644
--- a/AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java
+++ b/AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java
@@ -146,7 +146,7 @@ public class ARSCDecoder {
                 HashMap<String, String> fileMapping = config.mOldFileMapping;
                 List<String> keepFileNames = new ArrayList<String>();
                 //这里面为了兼容以前,也需要用以前的文件名前缀,即res混淆成什么
-                String resRoot = null;
+                String resRoot = TypedValue.RES_FILE_PATH;
                 for (String name : fileMapping.values()) {
                     int dot = name.indexOf("/");
                     if (dot == -1) {
simpleton commented 8 years ago

Thanks for your issue and welcome pull request.