shwenzhang/AndResGuard · error · java.io.IOException

the file count of , and the file count of is not equal…

Error message

the file count of %s, and the file count of %s is not equal, there must be some problem

What it means

Integrity check in ResourceApkBuilder.generalUnsignApk: after repackaging, the file count of the destination res directory (destResDir) differs from the raw res directory (rawResDir). Since resource obfuscation must rename but not add or drop files, a count mismatch proves the repackage corrupted or lost resources, so the build aborts rather than shipping a broken APK.

Solutions

  1. Compare the files in the destination res directory and the raw res directory to find which resources were lost or added during resource shrinking/obfuscation
  2. Check whether resource shrinking (mKeepRoot / res dir handling) accidentally deleted needed files, and adjust keep rules or disable the problematic shrink step
  3. Re-run the build from an earlier clean state to rule out stale output in mOutDir
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at AndResGuard-core/src/main/java/com/tencent/mm/androlib/ResourceApkBuilder.java:337 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at AndResGuard-core/src/main/java/com/tencent/mm/androlib/ResourceApkBuilder.java:337

      collectFiles.add(f);
    }

    File destResDir = new File(mOutDir.getAbsolutePath(), "res");
    //添加修改后的res文件
    if (!config.mKeepRoot && FileOperation.getlist(destResDir) == 0) {
      destResDir = new File(mOutDir.getAbsolutePath(), TypedValue.RES_FILE_PATH);
    }

    /*
     * NOTE:文件数量应该是一样的,如果不一样肯定有问题
     */
    File rawResDir = new File(tempOutDir.getAbsolutePath() + File.separator + "res");
    System.out.printf("DestResDir %d rawResDir %d\n",
        FileOperation.getlist(destResDir),
        FileOperation.getlist(rawResDir)
    );
    if (FileOperation.getlist(destResDir) != (FileOperation.getlist(rawResDir) - ARSCDecoder.mMergeDuplicatedResCount)) {
      throw new IOException(String.format(
          "the file count of %s, and the file count of %s is not equal, there must be some problem\n",
          rawResDir.getAbsolutePath(),
          destResDir.getAbsolutePath()
      ));
    }
    if (!destResDir.exists()) {
      System.err.printf("Missing res files, path=%s\n", destResDir.getAbsolutePath());
      System.exit(-1);
    }
    //这个需要检查混淆前混淆后,两个res的文件数量是否相等
    collectFiles.add(destResDir);
    File rawARSCFile = new File(mOutDir.getAbsolutePath() + File.separator + "resources.arsc");
    if (!rawARSCFile.exists()) {
      System.err.printf("Missing resources.arsc files, path=%s\n", rawARSCFile.getAbsolutePath());
      System.exit(-1);
    }
    collectFiles.add(rawARSCFile);
    FileOperation.zipFiles(collectFiles, tempOutDir, mUnSignedApk, compressData);

View on GitHub (pinned to e4df245d82)