{"record":{"id":"6d86bb099bcffe91","repo":"Tencent/matrix","slug":"resguard-mapping-file-config-getresmappingfile","errorCode":null,"errorMessage":"---resguard mapping file <config.getResMappingFilePath()> is not legal!","messagePattern":"---resguard mapping file <config\\.getResMappingFilePath\\(\\)> is not legal!","errorType":"exception","errorClass":"TaskInitException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnzipTask.java","lineNumber":106,"sourceCode":"            throw new TaskInitException(TAG + \"---'\" + config.getApkPath() + \"' is not exist!\");\n        }\n        if (Util.isNullOrNil(config.getUnzipPath())) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH can not be null!\");\n        }\n        Log.i(TAG, \"outputPath:%s\", config.getUnzipPath());\n        outputFile = new File(config.getUnzipPath());\n\n        if (!Util.isNullOrNil(config.getMappingFilePath())) {\n            mappingTxt = new File(config.getMappingFilePath());\n            if (!FileUtil.isLegalFile(mappingTxt)) {\n                throw new TaskInitException(TAG + \"---mapping file \" + config.getMappingFilePath() + \" is not legal!\");\n            }\n        }\n\n        if (!Util.isNullOrNil(config.getResMappingFilePath())) {\n            resMappingTxt = new File(config.getResMappingFilePath());\n            if (!FileUtil.isLegalFile(resMappingTxt)) {\n                throw new TaskInitException(TAG + \"---resguard mapping file \" + config.getResMappingFilePath() + \" is not legal!\");\n            }\n        }\n    }\n\n    private void readMappingTxtFile() throws IOException {\n        if (mappingTxt != null) {\n            BufferedReader bufferedReader = new BufferedReader(new FileReader(mappingTxt));\n            String line = bufferedReader.readLine();\n            String beforeClass = \"\", afterClass = \"\";\n            try {\n                while (line != null) {\n                    if (!line.startsWith(\" \")) {\n                        String[] pair = line.split(\"->\");\n                        if (pair.length == 2) {\n                            beforeClass = pair[0].trim();\n                            afterClass = pair[1].trim();\n                            afterClass = afterClass.substring(0, afterClass.length() - 1);\n                            if (!Util.isNullOrNil(beforeClass) && !Util.isNullOrNil(afterClass)) {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnzipTask.java#L88-L124","documentation":"UnzipTask.init() validates the optional resource-guard (resguard) mapping file: if config.getResMappingFilePath() is set, FileUtil.isLegalFile must pass, otherwise TaskInitException is thrown with the configured path in the message. This mapping maps obfuscated resource names back to originals.","triggerScenarios":"Setting a non-empty resMappingFilePath that points to a missing, unreadable, or directory path (e.g. a resguard mapping from a previous build).","commonSituations":"Using WeChat resguard builds where the resource mapping file was regenerated/moved; stale path after clean; pointing to the resguard mapping of a different APK.","solutions":["Verify the configured resguard mapping file exists and is readable, and update the path.","Regenerate the resguard mapping from the same build that produced the APK being analyzed.","Omit resMappingFilePath if the APK was not processed by resguard."],"exampleFix":"// before\nconfig.setResMappingFilePath(\"resguard-mapping.txt\"); // missing\n// after\nFile rm = new File(\"build/resguard/mapping.txt\");\nif (rm.isFile()) config.setResMappingFilePath(rm.getAbsolutePath());","handlingStrategy":"validation","validationCode":"String p = config.getResMappingFilePath();\nif (p != null && !p.isEmpty()) {\n    File f = new File(p);\n    if (!f.isFile() || !f.canRead()) {\n        throw new IllegalArgumentException(\"resguard mapping not readable: \" + p);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.init();\n} catch (TaskInitException e) {\n    if (e.getMessage().contains(\"resguard mapping\")) {\n        config.setResMappingFilePath(null); // proceed without resguard decoding\n    } else throw e;\n}","preventionTips":["Only set the resguard mapping when the APK was actually processed by resguard.","Keep resguard output paths derived from the resguard task's outputs, not constants."],"tags":["apk-canary","resguard","mapping-file","invalid-path"],"backgroundTag":"invalid-config-value","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}