skylot/jadx · error · JadxRuntimeException

Gradle export failed

Error message

Gradle export failed

What it means

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.

Source

Thrown at jadx-core/src/main/java/jadx/core/export/gen/AndroidGradleGenerator.java:70

		String moduleDir = exportApp ? "app" : "lib";
		baseDir = new File(projectDir, moduleDir);
		outDirs = new OutDirs(new File(baseDir, "src/main/java"), new File(baseDir, "src/main"));
		applicationParams = parseApplicationParams();
	}

	@Override
	public void generateFiles() {
		try {
			saveProjectBuildGradle();
			if (exportApp) {
				saveApplicationBuildGradle();
			} else {
				saveLibraryBuildGradle();
			}
			saveSettingsGradle();
			saveGradleProperties();
		} catch (Exception e) {
			throw new JadxRuntimeException("Gradle export failed", e);
		}
	}

	@Override
	public OutDirs getOutDirs() {
		return outDirs;
	}

	private ApplicationParams parseApplicationParams() {
		try {
			ResourceFile androidManifest = AndroidManifestParser.getAndroidManifest(resources);
			if (androidManifest == null) {
				LOG.warn("AndroidManifest.xml not found, exported files will contains 'null' fields");
				return new ApplicationParams();
			}
			ResContainer strings = null;
			if (exportApp) {
				ResourceFile arscFile = resources.stream()

View on GitHub (pinned to e738a26571)

Solutions

  1. Inspect the wrapped exception via Throwable#getCause() to identify the root failure (I/O error, missing template, null field, etc.).
  2. Verify the output directory is writable and has sufficient disk space.
  3. Check that the input APK/JAR has the expected resources (AndroidManifest.xml for Android exports).
  4. Ensure you are using a complete jadx build (templates are bundled in the jadx-core JAR under /export/).
  5. If the cause is a template variable error, report it as a jadx bug with the input file.
Defensive patterns

Strategy: try-catch

Validate before calling

// Before export, verify output directory is writable
File outDir = new File(projectDir);
if (!outDir.exists() && !outDir.mkdirs()) {
    throw new IOException("Cannot create output directory: " + outDir);
}
if (!outDir.canWrite()) {
    throw new IOException("Output directory not writable: " + outDir);
}

Try / catch

try {
    exportGradle.init();
    exportGradle.generateGradleFiles();
} catch (JadxRuntimeException e) {
    Throwable cause = e.getCause();
    if (cause instanceof IOException) {
        LOG.error("I/O error during Gradle export: {}", cause.getMessage());
    } else {
        LOG.error("Gradle export failed", e);
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14). Data as JSON: /api/errors/a59aaf1603d16556. Report an issue: GitHub.