{"record":{"id":"abe968f5f7a2599d","repo":"Tencent/matrix","slug":"the-resguard-mapping-file-resguard-mapping-txt","errorCode":null,"errorMessage":"---The Resguard mapping file 'resguard-mapping.txt' is not legal!","messagePattern":"---The Resguard mapping file 'resguard-mapping\\.txt' 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/UnusedResourcesTask.java","lineNumber":135,"sourceCode":"        } else if (!inputFile.isDirectory()) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH '\" + inputPath + \"' is not directory!\");\n        }\n        if (!Util.isNullOrNil(config.getMappingFilePath())) {\n            mappingTxt = new File(config.getMappingFilePath());\n            if (!FileUtil.isLegalFile(mappingTxt)) {\n                throw new TaskInitException(TAG + \"---The Proguard mapping file 'mapping.txt' is not legal!\");\n            }\n        }\n        if (params.containsKey(JobConstants.PARAM_IGNORE_RESOURCES_LIST) && !Util.isNullOrNil(params.get(JobConstants.PARAM_IGNORE_RESOURCES_LIST))) {\n            String[] ignoreRes = params.get(JobConstants.PARAM_IGNORE_RESOURCES_LIST).split(\",\");\n            for (String ignore : ignoreRes) {\n                ignoreSet.add(Util.globToRegexp(ignore));\n            }\n        }\n        if (!Util.isNullOrNil(config.getResMappingFilePath())) {\n            resMappingTxt = new File(config.getResMappingFilePath());\n            if (!FileUtil.isLegalFile(resMappingTxt)) {\n                throw new TaskInitException(TAG + \"---The Resguard mapping file 'resguard-mapping.txt' is not legal!\");\n            }\n        }\n\n        File[] files = inputFile.listFiles();\n        if (files != null) {\n            for (File file : files) {\n                if (file.isFile() && file.getName().endsWith(ApkConstants.DEX_FILE_SUFFIX)) {\n                    dexFileNameList.add(file.getName());\n                }\n            }\n        }\n\n    }\n\n    private String parseResourceId(String resId) {\n        if (!Util.isNullOrNil(resId) && resId.startsWith(\"0x\")) {\n            if (resId.length() == 10) {\n                return resId;","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnusedResourcesTask.java#L117-L153","documentation":"UnusedResourcesTask.init() throws TaskInitException when a resguard mapping file path is configured (config.getResMappingFilePath()) but the file is not legal (missing/unreadable). Resguard mapping is used when AndResGuard renamed resources.","triggerScenarios":"Setting resguard mapping path to a non-existent or unreadable resguard-mapping.txt, e.g., after cleaning the AndResGuard output.","commonSituations":"Projects using AndResGuard where the mapping output path changed between versions or the check runs before resguard completes.","solutions":["Verify resguard-mapping.txt exists at the configured path (run AndResGuard first)","Update config.setResMappingFilePath(...) to the current AndResGuard output path","Remove the resguard mapping config if the APK was not processed by AndResGuard"],"exampleFix":"// before\nconfig.setResMappingFilePath(\"build/outputs/resguard-mapping.txt\");\n// after\nconfig.setResMappingFilePath(\"app/build/outputs/apk/release/AndResGuard/resguard-mapping.txt\"); // exists after resguard runs","handlingStrategy":"validation","validationCode":"String rp = config.getResMappingFilePath();\nif (rp != null && !rp.isEmpty() && !(new File(rp).isFile())) {\n    throw new IllegalStateException(\"resguard-mapping.txt missing: \" + rp);\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.init();\n} catch (TaskInitException e) {\n    log.error(\"resguard mapping invalid: \" + e.getMessage());\n}","preventionTips":["Run AndResGuard before the unused-resources check","Resolve the resguard mapping path from the AndResGuard extension output, not hardcoded strings","Only configure resguard mapping for resguard-processed APKs"],"tags":["android","andresguard","apk-analysis"],"backgroundTag":"file-not-found","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"}