shwenzhang/AndResGuard · error · brut.androlib.AndrolibException
Could not decode arsc file
Error message
Could not decode arsc file
What it means
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.
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.
Example fix
// before
ResPackage[] pkgs = ARSCDecoder.decode(new FileInputStream(arsc), decoder);
// after
File arsc = new File(apkDir, "resources.arsc");
if (!arsc.exists() || arsc.length() == 0) {
throw new IllegalStateException("missing or empty resources.arsc: " + arsc);
}
try (InputStream in = new BufferedInputStream(new FileInputStream(arsc))) {
ResPackage[] pkgs = ARSCDecoder.decode(in, decoder);
} Defensive patterns
Strategy: try-catch
Validate before calling
File arsc = new File(apkDir, "resources.arsc");
if (!arsc.isFile() || arsc.length() == 0) {
throw new IllegalStateException("missing/empty resources.arsc");
} Try / catch
try {
ResPackage[] pkgs = ARSCDecoder.decode(in, decoder);
} catch (AndrolibException e) {
Throwable cause = e.getCause(); // the real IOException
throw new RuntimeException("arsc unreadable (corrupt or unsupported format): " + cause, e);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Can't Generate signed APK. Plz check your v1sign info is…
- Can't Generate signed APK v2. Plz check your v2sign info is…
- Can not found any signed apk file
- can not found the raw apk file to zipalign, path=
- writeTable package count is different before
AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12).
Data as JSON: /api/errors/24da5caad4336875.
Report an issue: GitHub.
Appendix: source
Thrown at AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java:121
private ARSCDecoder(InputStream arscStream, ApkDecoder decoder, ResPackage[] pkgs) throws FileNotFoundException {
mOldFileName = new LinkedHashMap<>();
mCurSpecNameToPos = new LinkedHashMap<>();
mShouldResguardTypeSet = new HashSet<>();
mApkDecoder = decoder;
mIn = new ExtDataInput(new LEDataInputStream(arscStream));
mOut = new ExtDataOutput(new LEDataOutputStream(new FileOutputStream(mApkDecoder.getOutTempARSCFile(), false)));
mPkgs = pkgs;
mPkgsLenghtChange = new int[pkgs.length];
}
public static ResPackage[] decode(InputStream arscStream, ApkDecoder apkDecoder) throws AndrolibException {
try {
ARSCDecoder decoder = new ARSCDecoder(arscStream, apkDecoder);
ResPackage[] pkgs = decoder.readTable();
return pkgs;
} catch (IOException ex) {
throw new AndrolibException("Could not decode arsc file", ex);
}
}
public static void write(InputStream arscStream, ApkDecoder decoder, ResPackage[] pkgs) throws AndrolibException {
try {
ARSCDecoder writer = new ARSCDecoder(arscStream, decoder, pkgs);
writer.writeTable();
} catch (IOException ex) {
throw new AndrolibException("Could not decode arsc file", ex);
}
}
private void proguardFileName() throws IOException, AndrolibException {
mMappingWriter = new BufferedWriter(new FileWriter(mApkDecoder.getResMappingFile(), false));
mMergeDuplicatedResMappingWriter = new BufferedWriter(new FileWriter(mApkDecoder.getMergeDuplicatedResMappingFile(), false));
mMergeDuplicatedResMappingWriter.write("res filter path mapping:\n");
mMergeDuplicatedResMappingWriter.flush();
View on GitHub (pinned to e4df245d82)