{"record":{"id":"28a0325df9ff7078","repo":"shwenzhang/AndResGuard","slug":"res-dest-file-is-already-found-destfile-s","errorCode":null,"errorMessage":"res dest file is already  found: destFile=%s","messagePattern":"res dest file is already  found: destFile=(.+?)","errorType":"exception","errorClass":"brut.androlib.AndrolibException","httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java","lineNumber":780,"sourceCode":"          if (filterInfo != null) {\n            resDestFile = new File(filterInfo.filePath);\n            result = filterInfo.fileName;\n          }\n        }\n\n        //这里用的是linux的分隔符\n        HashMap<String, Integer> compressData = mApkDecoder.getCompressData();\n        if (compressData.containsKey(raw)) {\n          compressData.put(result, compressData.get(raw));\n        } else {\n          System.err.printf(\"can not find the compress dataresFile=%s\\n\", raw);\n        }\n\n        if (!resRawFile.exists()) {\n          System.err.printf(\"can not find res file, you delete it? path: resFile=%s\\n\", resRawFile.getAbsolutePath());\n        } else {\n          if (!mergeDuplicatedRes && resDestFile.exists()) {\n            throw new AndrolibException(String.format(\"res dest file is already  found: destFile=%s\",\n               resDestFile.getAbsolutePath()\n            ));\n          }\n          if (filterInfo == null) {\n            FileOperation.copyFileUsingStream(resRawFile, resDestFile);\n          }\n          //already copied\n          mApkDecoder.removeCopiedResFile(resRawFile.toPath());\n          mTableStringsResguard.put(data, result);\n        }\n      }\n    }\n  }\n\n  /**\n   * resource filtering, filtering duplicate resources, reducing the volume of apk\n   */\n  private MergeDuplicatedResInfo mergeDuplicated(File resRawFile, File resDestFile, String compatibaleraw, String result) throws IOException {","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java#L762-L798","documentation":"After computing the destination file for an obfuscated resource, AndResGuard copies the raw file to the destination. If the destination already exists and mergeDuplicatedRes is disabled, two different source resources would collide at the same output path, so it throws to prevent silent overwrites. (A missing source file only logs a warning.)","triggerScenarios":"During arsc decoding/repackaging, two distinct resource entries map to the same destination path (name collision after obfuscation, e.g. identical short names assigned to resources in different types merged into one directory) while config.mMergeDuplicatedRes is false and resDestFile.exists().","commonSituations":"APKs with duplicate resources across densities/types that collapse to the same obfuscated name; re-running output into a dirty output directory containing files from a previous run; custom fixedResName settings causing name collisions.","solutions":["Clean the output directory before rebuilding so leftover files from prior runs don't count as collisions.","Enable mergeDuplicatedRes in the AndResGuard config to merge resources that resolve to the same destination instead of throwing.","Disable or adjust mFixedResName if a fixed name forces multiple resources onto one path.","Check the resguard naming config/whitelist for entries causing two resources to map to the same output path."],"exampleFix":"// before\nandResGuard {\n    fixedResName = \"r\" // all resources same name -> collisions\n}\n// after\nandResGuard {\n    mergeDuplicatedRes = true\n    // fixedResName = null\n}","handlingStrategy":"fallback","validationCode":"// clean output dir before build\ndeleteRecursively(new File(project.buildDir, \"AndResGuard\"));","typeGuard":null,"tryCatchPattern":"try {\n    ARSCDecoder.decode(arscStream, apkDecoder);\n} catch (AndrolibException e) {\n    if (e.getMessage().contains(\"already found\")) {\n        // enable mergeDuplicatedRes or clean the output directory and retry\n    }\n}","preventionTips":["Clean the AndResGuard output directory between builds.","Enable mergeDuplicatedRes for APKs known to contain duplicate resources.","Avoid fixedResName configurations that collapse many resources onto one path."],"tags":["duplicate-resources","obfuscation","collision","apk"],"backgroundTag":"file-already-exists","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"}