{"record":{"id":"4cfef91eb56b497d","repo":"skylot/jadx","slug":"failed-to-open-zip-file-file-getabsolutepath","errorCode":null,"errorMessage":"Failed to open zip file: ${file.getAbsolutePath()}","messagePattern":"Failed to open zip file: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/api/ResourcesLoader.java","lineNumber":211,"sourceCode":"\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// If no custom decoder was able to decode the resources, use the default decoder\n\t\tdefaultLoadFile(list, file, \"\");\n\t}\n\n\tpublic void defaultLoadFile(List<ResourceFile> list, File file, String subDir) {\n\t\tif (FileUtils.isZipFile(file)) {\n\t\t\ttry {\n\t\t\t\tZipContent zipContent = decompiler.getZipReader().open(file);\n\t\t\t\t// do not close a zip now, entry content will be read later\n\t\t\t\tdecompiler.addCloseable(zipContent);\n\t\t\t\tfor (IZipEntry entry : zipContent.getEntries()) {\n\t\t\t\t\taddEntry(list, file, entry, subDir);\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\tthrow new RuntimeException(\"Failed to open zip file: \" + file.getAbsolutePath(), e);\n\t\t\t}\n\t\t} else {\n\t\t\tResourceType type = ResourceType.getFileType(file.getAbsolutePath());\n\t\t\tlist.add(ResourceFile.createResourceFile(decompiler, file, type));\n\t\t}\n\t}\n\n\tpublic void addEntry(List<ResourceFile> list, File zipFile, IZipEntry entry, String subDir) {\n\t\tif (entry.isDirectory()) {\n\t\t\treturn;\n\t\t}\n\t\tString name = entry.getName();\n\t\tResourceType type = ResourceType.getFileType(name);\n\t\tResourceFile rf = ResourceFile.createResourceFile(decompiler, subDir + name, type);\n\t\tif (rf != null) {\n\t\t\trf.setZipEntry(entry);\n\t\t\tlist.add(rf);\n\t\t}","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/api/ResourcesLoader.java#L193-L229","documentation":"Thrown by ResourcesLoader.defaultLoadFile() when opening an input file that FileUtils.isZipFile() identified as a zip, but decompiler.getZipReader().open(file) then throws. jadx registers the ZipContent as a closeable and enumerates its entries; if open fails it wraps the cause in a RuntimeException naming the absolute path. This is part of resource discovery (loading the list of ResourceFiles from input files), not entry-level decoding.","triggerScenarios":"Calling resource loading on an input set containing a file that passes isZipFile() (has zip magic) but cannot be opened by the ZipReader (truncated, corrupt central directory, locked, or a false-positive zip signature).","commonSituations":"An APK/AAB/JAR in the input list that is truncated or corrupt; a file that happens to start with 'PK' but is not a real zip; a file exclusively locked by another process; a partially downloaded archive; a large zip that exceeds parser limits during resource scanning.","solutions":["Inspect getCause() to see the underlying open failure (IO, size-limit, structure).","Verify the file is a complete, valid zip before adding it to the input list.","Ensure no other process holds an exclusive lock on the file.","If the file is not meant to be treated as a zip, exclude it from the input set or rename it."],"exampleFix":"// before\nresLoader.defaultLoadFile(list, inputFile, \"\");\n\n// after\nif (FileUtils.isZipFile(inputFile)) {\n    try {\n        resLoader.defaultLoadFile(list, inputFile, \"\");\n    } catch (RuntimeException e) {\n        LOG.warn(\"Failed to open resource zip {}, skipping: {}\", inputFile.getAbsolutePath(), e.getCause());\n    }\n} else {\n    LOG.warn(\"Input {} is not a zip, skipping\", inputFile.getAbsolutePath());\n}","handlingStrategy":"try-catch","validationCode":"// Pre-validate the file is a real, openable zip before resource loading.\nif (FileUtils.isZipFile(file)) {\n    try (java.util.zip.ZipFile zf = new java.util.zip.ZipFile(file)) {\n        // ok\n    } catch (IOException e) {\n        LOG.warn(\"Skipping unreadable zip {}: {}\", file, e.getMessage());\n        return;\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    resLoader.defaultLoadFile(list, file, subDir);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Failed to open zip file\")) {\n        LOG.warn(\"Skipping resource zip {}: {}\", file, e.getCause());\n    } else throw e;\n}","preventionTips":["Confirm each input zip is complete and not locked before resource loading.","Inspect getCause() for the underlying open failure.","Skip unreadable resource archives rather than aborting the whole load."],"tags":["resources","zip","io","corrupted-archive"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}