{"record":{"id":"593352a74be67a1d","repo":"skylot/jadx","slug":"resource-not-found","errorCode":null,"errorMessage":"Resource not found: {}","messagePattern":"Resource not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/export/TemplateFile.java","lineNumber":46,"sourceCode":"\t\tNONE, START, VARIABLE, END\n\t}\n\n\tprivate static class ParserState {\n\t\tprivate State state = State.NONE;\n\t\tprivate StringBuilder curVariable;\n\t\tprivate boolean skip;\n\t}\n\n\tprivate final String templateName;\n\tprivate final InputStream template;\n\tprivate final Map<String, String> values = new HashMap<>();\n\n\tprivate @Nullable Function<String, String> valueSanitizer;\n\n\tpublic static TemplateFile fromResources(String path) throws FileNotFoundException {\n\t\tInputStream res = TemplateFile.class.getResourceAsStream(path);\n\t\tif (res == null) {\n\t\t\tthrow new FileNotFoundException(\"Resource not found: \" + path);\n\t\t}\n\t\treturn new TemplateFile(path, res);\n\t}\n\n\tprivate TemplateFile(String name, InputStream in) {\n\t\tthis.templateName = name;\n\t\tthis.template = in;\n\t}\n\n\tpublic void add(String name, @Nullable Object value) {\n\t\tvalues.put(name, String.valueOf(value));\n\t}\n\n\tpublic String build() throws IOException {\n\t\ttry (ByteArrayOutputStream out = new ByteArrayOutputStream()) {\n\t\t\tprocess(out);\n\t\t\treturn out.toString();\n\t\t}","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/export/TemplateFile.java#L28-L64","documentation":"Thrown as FileNotFoundException by TemplateFile.fromResources() when Class.getResourceAsStream(path) returns null, meaning no resource exists at the given path on the classpath. TemplateFile is a lightweight template engine that loads .tmpl files from the jadx-core JAR's resources. A null stream indicates the template file is missing from the distribution or the path is wrong.","triggerScenarios":"TemplateFile.fromResources(path) is called with a path that does not match any bundled resource. Paths are absolute (must start with '/'), e.g. '/export/java/settings.gradle.kts.tmpl'. This is called by the Gradle generators during export, and potentially by other template consumers.","commonSituations":"Using an incomplete or corrupted jadx build where template resources were stripped from the JAR (e.g. by an aggressive shading/proguard step). Passing a wrong template path from custom code. Resource path case-sensitivity issues on case-sensitive filesystems.","solutions":["Verify the template resource exists inside the jadx-core JAR (unzip and check under /export/).","Ensure the path starts with '/' and matches the exact resource path (case-sensitive).","Re-download or rebuild jadx from source to get a complete distribution.","If developing custom export code, confirm the template path matches an actual resource file in src/main/resources."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the resource exists before creating a TemplateFile\nif (TemplateFile.class.getResource(path) == null) {\n    throw new FileNotFoundException(\"Template resource not on classpath: \" + path);\n}\nTemplateFile tmpl = TemplateFile.fromResources(path);","typeGuard":null,"tryCatchPattern":"try {\n    TemplateFile tmpl = TemplateFile.fromResources(path);\n} catch (FileNotFoundException e) {\n    LOG.error(\"Template resource missing: {}. Ensure jadx-core JAR is complete.\", path);\n    return;\n}","preventionTips":["Verify template resources are packaged in the jadx-core JAR under /export/.","Ensure paths start with '/' and match exact resource paths (case-sensitive).","Use a complete, unmodified jadx distribution.","If building jadx from source, confirm resources are included in the build (check build.gradle.kts resource configuration)."],"tags":["jadx","template","resource-not-found","classpath","file-not-found"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}