iBotPeaches/Apktool · error · AndrolibException
Could not load resources.arsc from file: {apkFile}
Error message
Could not load resources.arsc from file: {apkFile} What it means
Thrown by ResTable when opening an APK and parsing its resources.arsc fails with a DirectoryException or IOException. The message names the APK file, and the original exception is attached as the cause. It almost always means the file is not a readable ZIP or the resources.arsc entry is missing/corrupt.
Source
Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResTable.java:142
try (InputStream in = zipDir.getFileInput("resources.arsc")) {
BinaryResourceParser parser = isMainPackage
? new BinaryResourceParser(this, mConfig.isKeepBrokenResources(), mConfig.isDecodeResolveGreedy())
: new BinaryResourceParser(this, true, true);
parser.parse(in);
// Only flag the app for the main package.
if (isMainPackage) {
if (parser.hasSparseEntries()) {
mApkInfo.getResourcesInfo().setSparseEntries(true);
}
if (parser.hasCompactEntries()) {
mApkInfo.getResourcesInfo().setCompactEntries(true);
}
}
}
} catch (DirectoryException | IOException ex) {
throw new AndrolibException("Could not load resources.arsc from file: " + apkFile, ex);
}
}
public boolean hasPackageGroup(int id) {
return mPackageGroups.containsKey(id);
}
public ResPackageGroup getPackageGroup(int id) throws UndefinedResObjectException {
ResPackageGroup pkgGroup = mPackageGroups.get(id);
if (pkgGroup == null) {
throw new UndefinedResObjectException(String.format("package group: id=0x%02x", id));
}
return pkgGroup;
}
public ResPackageGroup addPackageGroup(int id, String name) throws AndrolibException {
ResPackageGroup pkgGroup = mPackageGroups.get(id);
if (pkgGroup != null) {View on GitHub (pinned to 79b63384d7)
Solutions
- Verify the file is a valid ZIP: `unzip -l app.apk` and confirm a resources.arsc entry exists
- If it is an XAPK/APKS bundle, extract the real base APK (and splits) first and decode those
- If resources.arsc is missing entirely, decode with resources disabled (e.g. `-s` / do not decode resources) since there is nothing to parse
- Re-download or re-pull the APK (adb pull) in case of transfer corruption; check the cause chain in the AndrolibException for the underlying ZIP error
Example fix
// before
new ApkDecoder().decode(new File("app.xapk"), outDir);
// after
// extract the base APK from the XAPK bundle first
try (ZipFile xapk = new ZipFile("app.xapk")) {
ZipEntry base = xapk.getEntry("base.apk");
try (InputStream in = xapk.getInputStream(base)) {
Files.copy(in, Path.of("base.apk"), StandardCopyOption.REPLACE_EXISTING);
}
}
new ApkDecoder().decode(new File("base.apk"), outDir); Defensive patterns
Strategy: validation
Validate before calling
// before calling ApkDecoder.decode
File apk = new File(path);
try (ZipFile zf = new ZipFile(apk)) {
boolean hasArsc = zf.getEntry("resources.arsc") != null;
if (!hasArsc) {
System.err.println("No resources.arsc in " + apk + " — decode with resources skipped");
}
} catch (IOException e) {
throw new IllegalArgumentException("Not a readable ZIP/APK: " + apk, e);
} Try / catch
try {
decoder.decode(apkFile, outDir);
} catch (AndrolibException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Could not load resources.arsc")) {
// inspect e.getCause(): DirectoryException = zip open failure, IOException = arsc read failure
log.error("Bad or resourceless APK: {}", apkFile, e.getCause());
} else { throw e; }
} Prevention
- Always run `unzip -t` on downloaded APKs before decoding
- Extract base APK from XAPK/APKS bundles before passing to apktool
- Check for resources.arsc presence up front and skip resource decoding when absent
When it happens
Trigger: Calling ApkDecoder.decode() (or any code path reaching ResTable.loadPackagesFromApk) on a file that is not a ZIP, has no resources.arsc entry, or whose ZIP central directory is truncated. Also triggered when the APK was re-zipped with a tool that broke entry names or compression.
Common situations: Decoding a downloaded/split APK that is actually an XAPK/ZIP bundle, decoding a DEX-only APK that has no resources, transferring an APK in text/ASCII mode corrupting bytes, or passing an OBB/odd archive instead of the real APK.
Related errors
- Could not find resources.arsc in file: {apkFile}
- Input file (" + path + ") was not found or was not readable.
- Destination directory (" + path + ") already exists. Use -f
- Could not find resources.arsc in file:
- No packages in resources.arsc in file.
AI-assisted analysis of iBotPeaches/Apktool@79b63384d7 (2026-08-14).
Data as JSON: /api/errors/b3a6330c24597b0d.
Report an issue: GitHub.