{"record":{"id":"8dcc78ef88cb9c30","repo":"Tencent/matrix","slug":"the-proguard-mapping-file-mapping-txt-is-not","errorCode":null,"errorMessage":"---The Proguard mapping file 'mapping.txt' is not legal!","messagePattern":"---The Proguard mapping file '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":123,"sourceCode":"            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH can not be null!\");\n        }\n        if (!params.containsKey(JobConstants.PARAM_R_TXT) || Util.isNullOrNil(params.get(JobConstants.PARAM_R_TXT))) {\n            throw new TaskInitException(TAG + \"---The File 'R.txt' can not be null!\");\n        }\n        resourceTxt = new File(params.get(JobConstants.PARAM_R_TXT));\n        if (!FileUtil.isLegalFile(resourceTxt)) {\n            throw new TaskInitException(TAG + \"---The Resource declarations file 'R.txt' is not legal!\");\n        }\n        inputFile = new File(inputPath);\n        if (!inputFile.exists()) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH '\" + inputPath + \"' is not exist!\");\n        } 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) {","sourceCodeStart":105,"sourceCodeEnd":141,"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#L105-L141","documentation":"UnusedResourcesTask.init() throws TaskInitException when a Proguard mapping file path is configured (config.getMappingFilePath() non-empty) but the file is not legal (missing/unreadable). Mapping is optional but must be valid when supplied, for resolving obfuscated code references.","triggerScenarios":"Setting mapping file path to a path from a previous build that was cleaned, or a typo'd/never-generated mapping.txt.","commonSituations":"Release builds with R8/ProGuard on CI where mapping.txt location changed or was deleted; passing minifiedBuild mapping path while building variant differs.","solutions":["Confirm mapping.txt exists at the configured path (regenerate via the release build)","Fix the path in config.setMappingFilePath(...) or clear it if code references aren't needed","Keep mapping.txt as a build artifact (retention) on CI before running the check"],"exampleFix":"// before\nconfig.setMappingFilePath(\"build/outputs/mapping/release/mapping.txt\"); // from old build\n// after\nconfig.setMappingFilePath(\"app/build/outputs/mapping/release/mapping.txt\"); // freshly generated, exists","handlingStrategy":"validation","validationCode":"String mp = config.getMappingFilePath();\nif (mp != null && !mp.isEmpty() && !(new File(mp).isFile())) {\n    throw new IllegalStateException(\"mapping.txt missing: \" + mp);\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.init();\n} catch (TaskInitException e) {\n    log.error(\"mapping.txt invalid: \" + e.getMessage());\n}","preventionTips":["Archive mapping.txt as CI artifact before running analysis","Regenerate mapping for the exact build being analyzed","Clear mappingFilePath for debug builds without obfuscation"],"tags":["android","proguard","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"}