skylot/jadx · error · JadxRuntimeException

Failed to write res-map file

Error message

Failed to write res-map file

What it means

Thrown when TextResMapFile.write fails to serialize the resource map to disk. The method builds a sorted TreeMap, formats each entry as '%08x=%s', and calls Files.write. Failures include: the target path's parent directory does not exist (NoSuchFileException), the filesystem is read-only or permissions are insufficient (AccessDeniedException), the disk is full (IOException), or the path points to an existing directory.

Source

Thrown at jadx-core/src/main/java/jadx/core/utils/android/TextResMapFile.java:59

	public static Map<Integer, String> read(Path resMapFile) {
		try (InputStream in = Files.newInputStream(resMapFile)) {
			return read(in);
		} catch (Exception e) {
			throw new JadxRuntimeException("Failed to read res-map file", e);
		}
	}

	public static void write(Path resMapFile, Map<Integer, String> inputResMap) {
		try {
			Map<Integer, String> resMap = new TreeMap<>(inputResMap);
			List<String> lines = new ArrayList<>(resMap.size());
			for (Map.Entry<Integer, String> entry : resMap.entrySet()) {
				lines.add(String.format("%08x=%s", entry.getKey(), entry.getValue()));
			}
			Files.write(resMapFile, lines, StandardCharsets.UTF_8);
		} catch (Exception e) {
			throw new JadxRuntimeException("Failed to write res-map file", e);
		}
	}
}

View on GitHub (pinned to e738a26571)

Solutions

  1. Create the parent directory before writing: Files.createDirectories(resMapFile.getParent()).
  2. Verify the parent directory is writable: Files.isWritable(resMapFile.getParent()).
  3. Check available disk space if running in constrained environments.
  4. Ensure the path does not collide with an existing directory name.

Example fix

// before
TextResMapFile.write(resMapPath, resMap);

// after
Path parent = resMapPath.getParent();
if (parent != null) Files.createDirectories(parent);
TextResMapFile.write(resMapPath, resMap);
Defensive patterns

Strategy: validation

Validate before calling

public static void ensureWritableTarget(Path file) throws IOException {
    Path parent = file.getParent();
    if (parent == null) parent = Path.of(".");
    Files.createDirectories(parent);
    if (!Files.isWritable(parent)) {
        throw new AccessDeniedException("cannot write to: " + parent);
    }
    if (Files.isDirectory(file)) {
        throw new IOException("target is a directory: " + file);
    }
}

Try / catch

try {
    TextResMapFile.write(resMapPath, resMap);
} catch (JadxRuntimeException e) {
    Throwable cause = e.getCause();
    if (cause instanceof NoSuchFileException) {
        // parent dir missing — create and retry
        Files.createDirectories(resMapPath.getParent());
        TextResMapFile.write(resMapPath, resMap);
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling TextResMapFile.write(Path, Map) where the parent directory of resMapFile has not been created yet. Calling it on a read-only filesystem or a path the JVM process lacks write permission for. Passing a Path that resolves to an already-existing directory. Running out of disk space during Files.write.

Common situations: Output directory not pre-created when saving a res-map to a deep nested path. Running jadx in a container with a read-only volume mount. Disk quota exceeded in CI environments. The output path was configured to a system directory like /opt or /etc that requires elevated permissions.

Related errors


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