{"record":{"id":"fcc28e791ff38095","repo":"skylot/jadx","slug":"zip-file-is-too-big","errorCode":null,"errorMessage":"Zip file is too big","messagePattern":"Zip file is too big","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"jadx-commons/jadx-zip/src/main/java/jadx/zip/parser/JadxZipParser.java","lineNumber":138,"sourceCode":"\t}\n\n\tprivate ByteBuffer getBuffer() {\n\t\tByteBuffer buf = byteBuffer;\n\t\tif (buf == null) {\n\t\t\tthrow new RuntimeException(\"File not opened: \" + zipFile);\n\t\t}\n\t\treturn buf;\n\t}\n\n\tprivate void load() throws IOException {\n\t\tif (byteBuffer != null) {\n\t\t\t// already loaded\n\t\t\treturn;\n\t\t}\n\t\tRandomAccessFile raFile = new RandomAccessFile(zipFile, \"r\");\n\t\tlong size = raFile.length();\n\t\tif (size >= Integer.MAX_VALUE) {\n\t\t\tthrow new IOException(\"Zip file is too big\");\n\t\t}\n\t\tint fileLen = (int) size;\n\t\tif (fileLen < 100 * 1024 * 1024) {\n\t\t\t// load files smaller than 100MB directly into memory\n\t\t\tbyte[] bytes = new byte[fileLen];\n\t\t\traFile.readFully(bytes);\n\t\t\tbyteBuffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN);\n\t\t\traFile.close();\n\t\t} else {\n\t\t\t// for big files - use a memory mapped file\n\t\t\tfile = raFile;\n\t\t\tfileChannel = raFile.getChannel();\n\t\t\tbyteBuffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size());\n\t\t\tbyteBuffer.order(ByteOrder.LITTLE_ENDIAN);\n\t\t}\n\t}\n\n\tprivate List<IZipEntry> searchLocalFileHeaders(int maxEntriesCount) {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-commons/jadx-zip/src/main/java/jadx/zip/parser/JadxZipParser.java#L120-L156","documentation":"A hard size gate in JadxZipParser.load(). The custom parser memory-maps or fully buffers the archive into a single ByteBuffer, whose capacity is an int, so any file whose length is >= Integer.MAX_VALUE (~2 GiB) cannot be represented and is rejected before any mapping is attempted. This is an architectural limit of the custom parser, not the fallback parser.","triggerScenarios":"Opening an archive whose RandomAccessFile.length() reports >= 2^31-1 bytes through the custom JadxZipParser. Files < 100 MiB are read into a heap byte[]; larger ones are memory-mapped, but both paths are gated by the same int-capacity check.","commonSituations":"Very large APKs, AABs, or supersets/zipped SDKs that exceed 2 GiB; a misidentified file (e.g., a disk image with a .zip extension); archives that grew past the limit after bundling many ABIs/assets.","solutions":["If the file genuinely exceeds 2 GiB, the custom parser cannot handle it; split or shrink the archive (e.g., split per-ABI APKs, remove debug assets).","Confirm the file is actually a zip and not a different large binary mislabeled.","Use ZipReaderFlags.FALLBACK_AS_DEFAULT so jadx uses the streaming fallback parser which is not bound by the single-buffer int limit.","Reduce the archive below the threshold by removing unused content."],"exampleFix":"// before\nZipContent content = zipReader.open(largeFile); // custom parser throws\n\n// after\nZipReader reader = new ZipReader(EnumSet.of(ZipReaderFlags.FALLBACK_AS_DEFAULT));\nZipContent content = reader.open(largeFile);","handlingStrategy":"validation","validationCode":"// Reject files at/above the 2 GiB custom-parser limit before opening.\nlong MAX = (long) Integer.MAX_VALUE; // ~2 GiB\nif (file.length() >= MAX) {\n    throw new IOException(\"Zip too large for custom parser (>= 2 GiB): \" + file.length());\n}","typeGuard":null,"tryCatchPattern":"try {\n    content = zipReader.open(file);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"too big\")) {\n        // switch to streaming fallback parser which is not int-capacity bound\n        reader = new ZipReader(EnumSet.of(ZipReaderFlags.FALLBACK_AS_DEFAULT));\n        content = reader.open(file);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Check file.length() against 2 GiB before opening if you handle large archives.","Use ZipReaderFlags.FALLBACK_AS_DEFAULT for inputs that may exceed the custom parser limit.","Split oversized APKs (per-ABI splits) to stay under the limit."],"tags":["zip","size-limit","io","configuration"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}