{"record":{"id":"909f13355bd072f1","repo":"shwenzhang/AndResGuard","slug":"could-not-find-old-mapping-file-s","errorCode":null,"errorMessage":"Could not find old mapping file %s","messagePattern":"Could not find old mapping file (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/com/tencent/mm/resourceproguard/Configuration.java","lineNumber":468,"sourceCode":"      throw new IOException(String.format(\"the old mapping file do not exit, raw path= %s\\n\",\n          mOldMappingFile.getAbsolutePath()\n      ));\n    }\n    processOldMappingFile();\n    System.out.printf(\"you are using the keepmapping mode to proguard resouces: old mapping path:%s\\n\",\n        mOldMappingFile.getAbsolutePath()\n    );\n  }\n\n  private void processOldMappingFile() throws IOException {\n    mOldResMapping.clear();\n    mOldFileMapping.clear();\n\n    FileReader fr;\n    try {\n      fr = new FileReader(mOldMappingFile);\n    } catch (FileNotFoundException ex) {\n      throw new IOException(String.format(\"Could not find old mapping file %s\", mOldMappingFile.getAbsolutePath()));\n    }\n    BufferedReader br = new BufferedReader(fr);\n    try {\n      String line = br.readLine();\n\n      while (line != null) {\n        if (line.length() > 0) {\n          Matcher mat = MAP_PATTERN.matcher(line);\n\n          if (mat.find()) {\n            String nameAfter = mat.group(2);\n            String nameBefore = mat.group(1);\n            nameAfter = nameAfter.trim();\n            nameBefore = nameBefore.trim();\n\n            //如果有这个的话，那就是mOldFileMapping\n            if (line.contains(\"/\")) {\n              mOldFileMapping.put(nameBefore, nameAfter);","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/resourceproguard/Configuration.java#L450-L486","documentation":"processOldMappingFile wraps its FileReader construction and, if the file cannot be opened (FileNotFoundException), rethrows this IOException naming the absolute path. This is a second, defensive check after readOldMapping's exists() test — it covers races and permission/open failures between the exists() check and the open, or when exists() passed but the path is a directory.","triggerScenarios":"Opening mOldMappingFile with new FileReader(mOldMappingFile) throws FileNotFoundException — the mapping file was deleted between the exists() check and the read, is actually a directory, or is unreadable due to permissions on some filesystems.","commonSituations":"Concurrent CI jobs cleaning build outputs while AndResGuard runs; a <keepmapping> path pointing at a directory instead of mapping.txt; sandboxed environments denying read access.","solutions":["Re-run the build ensuring the mapping file still exists and is a regular readable file at the configured path","Check that the path is a file, not a directory, and that the running user has read permission","If the file is generated by a prior task, serialize the pipeline so nothing deletes it mid-run"],"exampleFix":"// before\nmOldMappingFile = new File(\"build/outputs/mapping\"); // directory, not the file\n// after\nmOldMappingFile = new File(\"build/outputs/mapping/release/mapping.txt\");","handlingStrategy":"try-catch","validationCode":"java.io.File f = new java.io.File(mappingPath);\nif (!f.exists() || !f.isFile() || !f.canRead()) {\n  throw new IllegalStateException(\"mapping file must be a readable regular file: \" + f.getAbsolutePath());\n}","typeGuard":null,"tryCatchPattern":"try {\n  new Configuration(configFile, ...);\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Could not find old mapping file\")) {\n    // re-check that the file was not deleted/concurrently modified between config parse and read\n  }\n  throw e;\n}","preventionTips":["Avoid concurrent build jobs that clean the same output directory","Point keepmapping at mapping.txt, never at its containing directory","Ensure filesystem permissions allow read for the build user"],"tags":["android","mapping","file-io","filenotfound"],"backgroundTag":"file-open-failed","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"}