{"record":{"id":"510dc605bfbc832f","repo":"skylot/jadx","slug":"error-decode-rf-getoriginalname","errorCode":null,"errorMessage":"Error decode: ${rf.getOriginalName()}","messagePattern":"Error decode: (.+?)","errorType":"exception","errorClass":"JadxException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/api/ResourcesLoader.java","lineNumber":109,"sourceCode":"\tpublic void addResTableParserProvider(IResTableParserProvider resTableParserProvider) {\n\t\tresTableParserProviders.add(resTableParserProvider);\n\t}\n\n\tpublic static <T> T decodeStream(ResourceFile rf, ResourceDecoder<T> decoder) throws JadxException {\n\t\ttry {\n\t\t\tIZipEntry zipEntry = rf.getZipEntry();\n\t\t\tif (zipEntry != null) {\n\t\t\t\ttry (InputStream inputStream = zipEntry.getInputStream()) {\n\t\t\t\t\treturn decoder.decode(zipEntry.getUncompressedSize(), inputStream);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tFile file = new File(rf.getOriginalName());\n\t\t\t\ttry (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) {\n\t\t\t\t\treturn decoder.decode(file.length(), inputStream);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tthrow new JadxException(\"Error decode: \" + rf.getOriginalName(), e);\n\t\t}\n\t}\n\n\tstatic ResContainer loadContent(JadxDecompiler jadxRef, ResourceFile rf) {\n\t\ttry {\n\t\t\tResourcesLoader resLoader = jadxRef.getResourcesLoader();\n\t\t\treturn decodeStream(rf, (size, is) -> resLoader.loadContent(rf, is));\n\t\t} catch (JadxException e) {\n\t\t\tLOG.error(\"Decode error\", e);\n\t\t\tICodeWriter cw = jadxRef.getRoot().makeCodeWriter();\n\t\t\tcw.add(\"Error decode \").add(rf.getType().toString().toLowerCase());\n\t\t\tUtils.appendStackTrace(cw, e.getCause());\n\t\t\treturn ResContainer.textResource(rf.getDeobfName(), cw.finish());\n\t\t}\n\t}\n\n\tprivate ResContainer loadContent(ResourceFile resFile, InputStream inputStream) throws IOException {\n\t\tfor (IResContainerFactory customFactory : resContainerFactories) {","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/api/ResourcesLoader.java#L91-L127","documentation":"Thrown by ResourcesLoader.decodeStream() when a ResourceDecoder.decode() call fails while reading a resource entry's content. Unlike the RuntimeExceptions elsewhere, this is a checked JadxException wrapping the original IOException/exception, carrying the resource's original name. It fires for both zip-backed entries (via IZipEntry.getInputStream) and plain-file resources (via FileInputStream). The higher-level loadContent() catches it and degrades to an error-code snippet rather than crashing.","triggerScenarios":"Decoding a ResourceFile (image, XML, binary resource) through a ResourceDecoder whose decode(size, inputStream) throws, for an entry whose underlying stream is corrupt or whose format the decoder cannot parse.","commonSituations":"A malformed binary resource (e.g., a corrupt .arsc, a truncated .png, a 9-patch that fails decoding); a resource type mismatch where the decoder chosen for the extension cannot parse the bytes; a zip entry whose stream throws mid-read; disk I/O errors on an extracted resource.","solutions":["Inspect getCause() to see the decode-specific error (image lib, XML parser, ARSC parser).","Use the higher-level loadContent() which already catches JadxException and returns an error placeholder instead of propagating.","Skip the offending resource and continue with the rest.","Verify the resource bytes are intact (re-extract/re-download the archive)."],"exampleFix":"// before\nT result = ResourcesLoader.decodeStream(rf, (size, is) -> decoder.decode(size, is));\n\n// after\nT result;\ntry {\n    result = ResourcesLoader.decodeStream(rf, (size, is) -> decoder.decode(size, is));\n} catch (JadxException e) {\n    LOG.warn(\"Failed to decode resource {}, skipping: {}\", rf.getOriginalName(), e.getCause());\n    result = null;\n}","handlingStrategy":"try-catch","validationCode":"// Prefer the higher-level loadContent() which already catches JadxException\n// and degrades to an error-code placeholder. If calling decodeStream directly,\n// guard the decoder:\nObjects.requireNonNull(decoder, \"decoder\");\nif (rf.getType() == null) throw new JadxException(\"Unknown resource type for \" + rf.getOriginalName());","typeGuard":null,"tryCatchPattern":"try {\n    return ResourcesLoader.decodeStream(rf, (size, is) -> decoder.decode(size, is));\n} catch (JadxException e) {\n    LOG.warn(\"Decode failed for {}: {}\", rf.getOriginalName(), e.getCause());\n    return null; // or an error placeholder\n}","preventionTips":["Use loadContent() instead of decodeStream() to get built-in error degradation.","Inspect getCause() for the format-specific decode error.","Skip corrupt resources and continue rather than aborting the whole batch."],"tags":["resources","io","decoding","android"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}