pxb1988/dex2jar · error · ZipException
signature not found; was
Error message
signature not found; was
What it means
throwZipException builds the standard 'X signature not found; was 0x????????' message: an expected 4-byte record magic was absent at the position where a zip structure (local file header, central directory entry, EOCD) was being read, and the bytes actually found are reported in hex.
Solutions
- Re-obtain or repair the archive (zip -FF)
- Check for prepended bytes and recompute the real central directory offset
- Validate the file is a zip before parsing (check EOCD and signatures)
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// verify central directory offset region begins with CENSIG before deep parsing
raf.position(centralDirOffset);
if (raf.getInt() != 0x02014b50) throw new IOException("central dir signature missing"); Type guard
null
Try / catch
try { ZipFile z = new ZipFile(f); } catch (ZipException e) { log.error(e.getMessage()); /* message already contains found magic in hex */ } Prevention
- Validate DEX/APK integrity (checksums, signatures) before zip parsing
- Avoid tools that rewrite zips in place without fixing offsets
- Log the hex value from the message to identify which structure was corrupted
When it happens
Trigger: Reading a central directory entry or local file header whose magic does not match (CENSIG/LOCSIG), usually because offsets are wrong or the file is corrupted/not a zip.
Common situations: Corrupted or hand-modified zips/APKs, wrong central directory offset after prepended data, parsing non-zip files as zips.
Understand the failure class
Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.
Related errors
- File too short to be a zip file:
- End Of Central Directory signature not found
- File too small to be a dex/zip
- Can not find classes.dex in zip file
- File too small to be a dex/zip
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/3e02b4c7df2136ba.
Report an issue: GitHub.
Appendix: source
Thrown at dex-reader/src/main/java/com/googlecode/d2j/util/zip/ZipFile.java:270
// We have to do this now (from the constructor) rather than lazily because the
// public API doesn't allow us to throw IOException except from the constructor
// or from getInputStream.
ByteBuffer buf = (ByteBuffer) raf.duplicate().order(ByteOrder.LITTLE_ENDIAN).position((int) centralDirOffset);
entries = new ArrayList<>(numEntries);
for (int i = 0; i < numEntries; ++i) {
ZipEntry newEntry = new ZipEntry(buf, skipCommentsAndExtra);
if (newEntry.localHeaderRelOffset >= centralDirOffset) {
// Ignore the entry
// throw new ZipException("Local file header offset is after central directory");
} else {
entries.add(newEntry);
}
}
}
static void throwZipException(String msg, int magic) throws ZipException {
final String hexString = String.format("0x%08x", magic);
throw new ZipException(msg + " signature not found; was " + hexString);
}
@Override
public void close() throws IOException {
if(file!=null){
file.close();
}
}
static class ZipInflaterInputStream extends InflaterInputStream {
private final ZipEntry entry;
private long bytesRead = 0;
public ZipInflaterInputStream(InputStream is, Inflater inf, int bsize, ZipEntry entry) {
super(is, inf, bsize);
this.entry = entry;
}
View on GitHub (pinned to b5bda4fb49)