shwenzhang/AndResGuard · error · brut.androlib.AndrolibException

res dest file is already found: destFile=

Error message

res dest file is already  found: destFile=%s

What it means

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.)

Solutions

  1. Clean the output directory before rebuilding so leftover files from prior runs don't count as collisions.
  2. Enable mergeDuplicatedRes in the AndResGuard config to merge resources that resolve to the same destination instead of throwing.
  3. Disable or adjust mFixedResName if a fixed name forces multiple resources onto one path.
  4. Check the resguard naming config/whitelist for entries causing two resources to map to the same output path.

Example fix

// before
andResGuard {
    fixedResName = "r" // all resources same name -> collisions
}
// after
andResGuard {
    mergeDuplicatedRes = true
    // fixedResName = null
}
Defensive patterns

Strategy: fallback

Validate before calling

// clean output dir before build
deleteRecursively(new File(project.buildDir, "AndResGuard"));

Try / catch

try {
    ARSCDecoder.decode(arscStream, apkDecoder);
} catch (AndrolibException e) {
    if (e.getMessage().contains("already found")) {
        // enable mergeDuplicatedRes or clean the output directory and retry
    }
}

Prevention

When it happens

Trigger: 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().

Common situations: 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.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12). Data as JSON: /api/errors/28a0325df9ff7078. Report an issue: GitHub.

Appendix: source

Thrown at AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java:780

          if (filterInfo != null) {
            resDestFile = new File(filterInfo.filePath);
            result = filterInfo.fileName;
          }
        }

        //这里用的是linux的分隔符
        HashMap<String, Integer> compressData = mApkDecoder.getCompressData();
        if (compressData.containsKey(raw)) {
          compressData.put(result, compressData.get(raw));
        } else {
          System.err.printf("can not find the compress dataresFile=%s\n", raw);
        }

        if (!resRawFile.exists()) {
          System.err.printf("can not find res file, you delete it? path: resFile=%s\n", resRawFile.getAbsolutePath());
        } else {
          if (!mergeDuplicatedRes && resDestFile.exists()) {
            throw new AndrolibException(String.format("res dest file is already  found: destFile=%s",
               resDestFile.getAbsolutePath()
            ));
          }
          if (filterInfo == null) {
            FileOperation.copyFileUsingStream(resRawFile, resDestFile);
          }
          //already copied
          mApkDecoder.removeCopiedResFile(resRawFile.toPath());
          mTableStringsResguard.put(data, result);
        }
      }
    }
  }

  /**
   * resource filtering, filtering duplicate resources, reducing the volume of apk
   */
  private MergeDuplicatedResInfo mergeDuplicated(File resRawFile, File resDestFile, String compatibaleraw, String result) throws IOException {

View on GitHub (pinned to e4df245d82)