skylot/jadx · error · IOException

Error reading library chunk at offset 0x%x

Error message

Error reading library chunk at offset 0x%x

What it means

After reading all library entries in a RES_TABLE_TYPE_LIBRARY chunk, the parser verifies the final stream position equals the expected chunk end. If the consumed bytes do not match chunkSize (e.g., count × entry-size < chunkSize), the chunk was not fully consumed, indicating a structural mismatch.

Source

Thrown at jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java:240

		}
	}

	private void parseLibraryTypeChunk(long chunkStart) throws IOException {
		LOG.trace("parsing library type chunk starting at offset {}", chunkStart);
		is.checkInt16(12, "Unexpected header size");
		int chunkSize = is.readInt32();
		long expectedEndPos = chunkStart + chunkSize;
		int count = is.readInt32();
		for (int i = 0; i < count; i++) {
			int packageId = is.readInt32();
			String packageName = is.readString16Fixed(128);
			LOG.info("Found resource shared library {}, pkgId: {}", packageName, packageId);
			if (is.getPos() > expectedEndPos) {
				throw new IOException("reading after chunk end");
			}
		}
		if (is.getPos() != expectedEndPos) {
			throw new IOException(String.format("Error reading library chunk at offset 0x%x", chunkStart));
		}
	}

	/**
	 * Parse an <code>ResTable_type</code> (except for the 2 bytes <code>uint16_t</code>
	 * from <code>ResChunk_header</code>).
	 *
	 * @see <a href=
	 *      "https://github.com/aosp-mirror/platform_frameworks_base/blob/master/libs/androidfw/include/androidfw/ResourceTypes.h"></a>ResourceTypes.h</a>
	 */
	private void parseTypeChunk(long start, PackageChunk pkg) throws IOException {
		/* int headerSize = */
		is.readInt16();
		/* int size = */
		long chunkSize = is.readUInt32();
		long chunkEnd = start + chunkSize;
		is.mark((int) chunkSize);

View on GitHub (pinned to e738a26571)

Solutions

  1. Re-extract resources from a clean APK
  2. Upgrade jadx to the latest version
  3. Report the APK to jadx maintainers
  4. Use --no-res to bypass resource parsing

Example fix

// Skip resource decoding:
jadxArgs.setSkipResources(true);
Defensive patterns

Strategy: try-catch

Try / catch

try {
    resTableParser.decode(stream);
} catch (IOException e) {
    if (e.getMessage().contains("library chunk")) {
        LOG.warn("Library chunk size mismatch, skipping resources", e);
        jadxArgs.setSkipResources(true);
    }
}

Prevention

When it happens

Trigger: parseLibraryTypeChunk finishes its loop and checks is.getPos() != expectedEndPos. Unlike the mid-loop check (247), this fires when fewer bytes were consumed than declared — the count field is too small, or chunkSize includes trailing data jadx does not parse.

Common situations: Malformed resources.arsc with inconsistent count/chunkSize. Newer library chunk format with additional trailing fields. Resource obfuscation tools.

Related errors


AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14). Data as JSON: /api/errors/2e0dad6588e82ced. Report an issue: GitHub.