{"record":{"id":"6e8abe73f908c6e0","repo":"shwenzhang/AndResGuard","slug":"the-old-mapping-res-file-path-should-be-like-r-a-yours-s","errorCode":null,"errorMessage":"the old mapping res file path should be like r/a, yours %s\n","messagePattern":"the old mapping res file path should be like r/a, yours (.+?)\n","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java","lineNumber":168,"sourceCode":"    for (File resFile : resFiles) {\n      String raw = resFile.getName();\n      if (raw.contains(\"-\")) {\n        raw = raw.substring(0, raw.indexOf(\"-\"));\n      }\n      mShouldResguardTypeSet.add(raw);\n    }\n\n    if (!config.mKeepRoot) {\n      // 需要保持之前的命名方式\n      if (config.mUseKeepMapping) {\n        HashMap<String, String> fileMapping = config.mOldFileMapping;\n        List<String> keepFileNames = new ArrayList<>();\n        // 这里面为了兼容以前，也需要用以前的文件名前缀，即res混淆成什么\n        String resRoot = TypedValue.RES_FILE_PATH;\n        for (String name : fileMapping.values()) {\n          int dot = name.indexOf(\"/\");\n          if (dot == -1) {\n            throw new IOException(String.format(\"the old mapping res file path should be like r/a, yours %s\\n\", name));\n          }\n          resRoot = name.substring(0, dot);\n          keepFileNames.add(name.substring(dot + 1));\n        }\n        // 去掉所有之前保留的命名，为了简单操作，mapping里面有的都去掉\n        mResguardBuilder.removeStrings(keepFileNames);\n\n        for (File resFile : resFiles) {\n          String raw = \"res\" + \"/\" + resFile.getName();\n          if (fileMapping.containsKey(raw)) {\n            mOldFileName.put(raw, fileMapping.get(raw));\n          } else {\n            mOldFileName.put(raw, resRoot + \"/\" + mResguardBuilder.getReplaceString());\n          }\n        }\n      } else {\n        for (int i = 0; i < resFiles.length; i++) {\n          // 这里也要用linux的分隔符,如果普通的话，就是r","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java#L150-L186","documentation":"During proguardFileName, when reusing an old resource-mapping file with keepMapping mode, every mapped value must be a path like \"r/a\" (res root directory + name, e.g. \"res/mipmap-x\" style prefix plus name). AndResGuard throws this IOException when a mapping value has no slash, so it cannot split it into the res root and the kept file name.","triggerScenarios":"Running with config.useKeepMapping (keep resource names) where the resource_mapping.txt provided via config.mMappingFile contains a line whose new-name value lacks a \"/\" — e.g. a hand-edited mapping with just \"icon\" instead of \"res/mipmap-x/icon\" or \"r/a\".","commonSituations":"Manually edited or machine-generated mapping files from older/different tools with the wrong format; typos when preserving resource names via keepMapping; mapping copied from a different build whose format doesn't match.","solutions":["Open the old resource_mapping.txt and fix the offending line so values look like \"res/dir/name\" (contain at least one \"/\").","Regenerate the mapping file from a previous successful AndResGuard run rather than hand-writing it.","Ensure you use the mapping file version matching the AndResGuard version (format changed across versions).","If you don't need to keep previous names, disable useKeepMapping so no old mapping is parsed."],"exampleFix":"// before (mapping entry)\nres/mipmap/ic_launcher -> ic_launcher\n// after\nres/mipmap/ic_launcher -> r/a","handlingStrategy":"validation","validationCode":"for (String line : Files.readAllLines(mappingFile.toPath())) {\n    int arrow = line.indexOf(\"->\");\n    String target = line.substring(arrow + 2).trim();\n    if (!target.contains(\"/\")) {\n        throw new IllegalStateException(\"mapping value must be like r/a: \" + target);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use mapping files generated by a previous AndResGuard run, never hand-edited ones.","Match mapping file format to the AndResGuard version.","Disable useKeepMapping when you don't need to preserve old names."],"tags":["mapping","keep-mapping","format","arsc"],"backgroundTag":"invalid-argument-format","analyzedSha":"e4df245d82f27d9a2d0dd108260a3510cbaba849","analyzedAt":"2026-09-12T17:49:07.798Z","contentChangedAt":"2026-09-12T17:49:07.798Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}