{"record":{"id":"a59aaf1603d16556","repo":"skylot/jadx","slug":"gradle-export-failed","errorCode":null,"errorMessage":"Gradle export failed","messagePattern":"Gradle export failed","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/export/gen/AndroidGradleGenerator.java","lineNumber":70,"sourceCode":"\t\tString moduleDir = exportApp ? \"app\" : \"lib\";\n\t\tbaseDir = new File(projectDir, moduleDir);\n\t\toutDirs = new OutDirs(new File(baseDir, \"src/main/java\"), new File(baseDir, \"src/main\"));\n\t\tapplicationParams = parseApplicationParams();\n\t}\n\n\t@Override\n\tpublic void generateFiles() {\n\t\ttry {\n\t\t\tsaveProjectBuildGradle();\n\t\t\tif (exportApp) {\n\t\t\t\tsaveApplicationBuildGradle();\n\t\t\t} else {\n\t\t\t\tsaveLibraryBuildGradle();\n\t\t\t}\n\t\t\tsaveSettingsGradle();\n\t\t\tsaveGradleProperties();\n\t\t} catch (Exception e) {\n\t\t\tthrow new JadxRuntimeException(\"Gradle export failed\", e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic OutDirs getOutDirs() {\n\t\treturn outDirs;\n\t}\n\n\tprivate ApplicationParams parseApplicationParams() {\n\t\ttry {\n\t\t\tResourceFile androidManifest = AndroidManifestParser.getAndroidManifest(resources);\n\t\t\tif (androidManifest == null) {\n\t\t\t\tLOG.warn(\"AndroidManifest.xml not found, exported files will contains 'null' fields\");\n\t\t\t\treturn new ApplicationParams();\n\t\t\t}\n\t\t\tResContainer strings = null;\n\t\t\tif (exportApp) {\n\t\t\t\tResourceFile arscFile = resources.stream()","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/export/gen/AndroidGradleGenerator.java#L52-L88","documentation":"Thrown as JadxRuntimeException by AndroidGradleGenerator.generateFiles() wrapping any exception thrown during Gradle project file generation. The method writes build.gradle, settings.gradle, and gradle.properties from templates. The original exception is attached as the cause, so inspecting getCause() is essential for diagnosis.","triggerScenarios":"Any exception during saveProjectBuildGradle(), saveApplicationBuildGradle()/saveLibraryBuildGradle(), saveSettingsGradle(), or saveGradleProperties(). Common causes: IOException from file I/O (permissions, disk full, path too long), FileNotFoundException for a missing template resource, TemplateFile syntax errors, or NullPointerException from missing AndroidManifest/application params.","commonSituations":"Exporting a decompiled APK as a Gradle project (via CLI --export-gradle or GUI export). Fails when the output directory is not writable, the input lacks an expected resource (AndroidManifest.xml), or a template variable is missing. Also possible with corrupted or heavily obfuscated APKs where resource parsing fails.","solutions":["Inspect the wrapped exception via Throwable#getCause() to identify the root failure (I/O error, missing template, null field, etc.).","Verify the output directory is writable and has sufficient disk space.","Check that the input APK/JAR has the expected resources (AndroidManifest.xml for Android exports).","Ensure you are using a complete jadx build (templates are bundled in the jadx-core JAR under /export/).","If the cause is a template variable error, report it as a jadx bug with the input file."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before export, verify output directory is writable\nFile outDir = new File(projectDir);\nif (!outDir.exists() && !outDir.mkdirs()) {\n    throw new IOException(\"Cannot create output directory: \" + outDir);\n}\nif (!outDir.canWrite()) {\n    throw new IOException(\"Output directory not writable: \" + outDir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    exportGradle.init();\n    exportGradle.generateGradleFiles();\n} catch (JadxRuntimeException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof IOException) {\n        LOG.error(\"I/O error during Gradle export: {}\", cause.getMessage());\n    } else {\n        LOG.error(\"Gradle export failed\", e);\n    }\n}","preventionTips":["Always inspect getCause() on the wrapped JadxRuntimeException to diagnose the root issue.","Verify output directory writability and disk space before export.","Ensure the input APK/JAR has expected resources (AndroidManifest.xml for Android exports).","Use a complete jadx build (templates bundled in jadx-core JAR)."],"tags":["jadx","gradle-export","android","io","wrapper-exception"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}