{"record":{"id":"fdbc69bc1c55a9f9","repo":"shwenzhang/AndResGuard","slug":"the-file-count-of-s-and-the-file-count-of-s-is-not-equal","errorCode":null,"errorMessage":"the file count of %s, and the file count of %s is not equal, there must be some problem\n","messagePattern":"the file count of (.+?), and the file count of (.+?) is not equal, there must be some problem\n","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/com/tencent/mm/androlib/ResourceApkBuilder.java","lineNumber":337,"sourceCode":"      collectFiles.add(f);\n    }\n\n    File destResDir = new File(mOutDir.getAbsolutePath(), \"res\");\n    //添加修改后的res文件\n    if (!config.mKeepRoot && FileOperation.getlist(destResDir) == 0) {\n      destResDir = new File(mOutDir.getAbsolutePath(), TypedValue.RES_FILE_PATH);\n    }\n\n    /*\n     * NOTE:文件数量应该是一样的，如果不一样肯定有问题\n     */\n    File rawResDir = new File(tempOutDir.getAbsolutePath() + File.separator + \"res\");\n    System.out.printf(\"DestResDir %d rawResDir %d\\n\",\n        FileOperation.getlist(destResDir),\n        FileOperation.getlist(rawResDir)\n    );\n    if (FileOperation.getlist(destResDir) != (FileOperation.getlist(rawResDir) - ARSCDecoder.mMergeDuplicatedResCount)) {\n      throw new IOException(String.format(\n          \"the file count of %s, and the file count of %s is not equal, there must be some problem\\n\",\n          rawResDir.getAbsolutePath(),\n          destResDir.getAbsolutePath()\n      ));\n    }\n    if (!destResDir.exists()) {\n      System.err.printf(\"Missing res files, path=%s\\n\", destResDir.getAbsolutePath());\n      System.exit(-1);\n    }\n    //这个需要检查混淆前混淆后，两个res的文件数量是否相等\n    collectFiles.add(destResDir);\n    File rawARSCFile = new File(mOutDir.getAbsolutePath() + File.separator + \"resources.arsc\");\n    if (!rawARSCFile.exists()) {\n      System.err.printf(\"Missing resources.arsc files, path=%s\\n\", rawARSCFile.getAbsolutePath());\n      System.exit(-1);\n    }\n    collectFiles.add(rawARSCFile);\n    FileOperation.zipFiles(collectFiles, tempOutDir, mUnSignedApk, compressData);","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/androlib/ResourceApkBuilder.java#L319-L355","documentation":"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.","triggerScenarios":"Thrown at AndResGuard-core/src/main/java/com/tencent/mm/androlib/ResourceApkBuilder.java:337 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["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","Check whether resource shrinking (mKeepRoot / res dir handling) accidentally deleted needed files, and adjust keep rules or disable the problematic shrink step","Re-run the build from an earlier clean state to rule out stale output in mOutDir"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}