{"record":{"id":"24da5caad4336875","repo":"shwenzhang/AndResGuard","slug":"could-not-decode-arsc-file","errorCode":null,"errorMessage":"Could not decode arsc file","messagePattern":"Could not decode arsc file","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":121,"sourceCode":"\n  private ARSCDecoder(InputStream arscStream, ApkDecoder decoder, ResPackage[] pkgs) throws FileNotFoundException {\n    mOldFileName = new LinkedHashMap<>();\n    mCurSpecNameToPos = new LinkedHashMap<>();\n    mShouldResguardTypeSet = new HashSet<>();\n    mApkDecoder = decoder;\n    mIn = new ExtDataInput(new LEDataInputStream(arscStream));\n    mOut = new ExtDataOutput(new LEDataOutputStream(new FileOutputStream(mApkDecoder.getOutTempARSCFile(), false)));\n    mPkgs = pkgs;\n    mPkgsLenghtChange = new int[pkgs.length];\n  }\n\n  public static ResPackage[] decode(InputStream arscStream, ApkDecoder apkDecoder) throws AndrolibException {\n    try {\n      ARSCDecoder decoder = new ARSCDecoder(arscStream, apkDecoder);\n      ResPackage[] pkgs = decoder.readTable();\n      return pkgs;\n    } catch (IOException ex) {\n      throw new AndrolibException(\"Could not decode arsc file\", ex);\n    }\n  }\n\n  public static void write(InputStream arscStream, ApkDecoder decoder, ResPackage[] pkgs) throws AndrolibException {\n    try {\n      ARSCDecoder writer = new ARSCDecoder(arscStream, decoder, pkgs);\n      writer.writeTable();\n    } catch (IOException ex) {\n      throw new AndrolibException(\"Could not decode arsc file\", ex);\n    }\n  }\n\n  private void proguardFileName() throws IOException, AndrolibException {\n    mMappingWriter = new BufferedWriter(new FileWriter(mApkDecoder.getResMappingFile(), false));\n    mMergeDuplicatedResMappingWriter = new BufferedWriter(new FileWriter(mApkDecoder.getMergeDuplicatedResMappingFile(), false));\n    mMergeDuplicatedResMappingWriter.write(\"res filter path mapping:\\n\");\n    mMergeDuplicatedResMappingWriter.flush();\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java#L103-L139","documentation":"ARSCDecoder.decode wraps any IOException raised while parsing the APK's resources.arsc stream into an AndrolibException with this message. It means the binary resource table could not be read — usually a corrupt/truncated resources.arsc or an I/O failure on the input stream.","triggerScenarios":"Calling ARSCDecoder.decode(arscStream, apkDecoder) where reading the stream throws IOException: corrupt or non-standard resources.arsc (e.g. built by non-AAPT tools, encrypted, or protected APK), truncated stream from an incomplete download/copy, or closed stream.","commonSituations":"Processing APKs obfuscated by other tools (e.g. other resguard/packers) that rewrite arsc incompatibly; corrupt APK artifacts in CI caches; APKs that fail resource verification.","solutions":["Verify the input APK is valid and its resources.arsc was produced by standard AAPT/AAPT2 — recompile or re-export the APK.","Check the underlying cause exception (AndrolibException cause) for the specific IOException (EOF, corrupt chunk).","Re-download/rebuild the APK; compare its sha1 to the original to rule out truncation.","If the APK was processed by another obfuscator, disable that step or use a version compatible with AndResGuard."],"exampleFix":"// before\nResPackage[] pkgs = ARSCDecoder.decode(new FileInputStream(arsc), decoder);\n// after\nFile arsc = new File(apkDir, \"resources.arsc\");\nif (!arsc.exists() || arsc.length() == 0) {\n    throw new IllegalStateException(\"missing or empty resources.arsc: \" + arsc);\n}\ntry (InputStream in = new BufferedInputStream(new FileInputStream(arsc))) {\n    ResPackage[] pkgs = ARSCDecoder.decode(in, decoder);\n}","handlingStrategy":"try-catch","validationCode":"File arsc = new File(apkDir, \"resources.arsc\");\nif (!arsc.isFile() || arsc.length() == 0) {\n    throw new IllegalStateException(\"missing/empty resources.arsc\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    ResPackage[] pkgs = ARSCDecoder.decode(in, decoder);\n} catch (AndrolibException e) {\n    Throwable cause = e.getCause(); // the real IOException\n    throw new RuntimeException(\"arsc unreadable (corrupt or unsupported format): \" + cause, e);\n}","preventionTips":["Verify APK integrity (sha1) before processing.","Use APKs built with standard AAPT2 and no other arsc-rewriting tools.","Keep AndResGuard updated for new arsc formats."],"tags":["arsc","decode","io","apk"],"backgroundTag":"file-read-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"}