skylot/jadx · error · JadxRuntimeException

Failed to list files in directory: ${dir}

Error message

Failed to list files in directory: ${dir}

What it means

Thrown by FileUtils.listFiles(Path) when Files.list(dir) throws an IOException. Files.list fails if the path does not exist, is not a directory (e.g., it's a regular file), or the process lacks permission to read/open the directory. The Stream is wrapped in try-with-resources so close() failures are unlikely to be the root cause.

Source

Thrown at jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java:87

			throw new JadxRuntimeException("Failed to update temp root directory", e);
		}
	}

	private static Path createTempRootDir() {
		try {
			Path dir = Files.createTempDirectory(JADX_TMP_INSTANCE_PREFIX);
			dir.toFile().deleteOnExit();
			return dir;
		} catch (Exception e) {
			throw new JadxRuntimeException("Failed to create temp root directory", e);
		}
	}

	public static List<Path> listFiles(Path dir) {
		try (Stream<Path> files = Files.list(dir)) {
			return files.collect(Collectors.toList());
		} catch (IOException e) {
			throw new JadxRuntimeException("Failed to list files in directory: " + dir, e);
		}
	}

	public static List<Path> listFiles(Path dir, Predicate<? super Path> filter) {
		try (Stream<Path> files = Files.list(dir)) {
			return files.filter(filter).collect(Collectors.toList());
		} catch (IOException e) {
			throw new JadxRuntimeException("Failed to list files in directory: " + dir, e);
		}
	}

	public static List<Path> expandDirs(List<Path> paths) {
		List<Path> files = new ArrayList<>(paths.size());
		for (Path path : paths) {
			if (Files.isDirectory(path)) {
				expandDir(path, files);
			} else {
				files.add(path);

View on GitHub (pinned to e738a26571)

Solutions

  1. Pre-check: Files.isDirectory(dir) and Files.isReadable(dir) before calling listFiles.
  2. Log or handle the specific cause (NoSuchFileException vs AccessDeniedException) from the JadxRuntimeException to guide the fix.
  3. If expanding an input set, filter out non-directory paths before calling listFiles.
  4. Verify the path is not a file masquerading as a directory name.

Example fix

// before
List<Path> files = FileUtils.listFiles(dir);

// after
if (!Files.isDirectory(dir) || !Files.isReadable(dir)) {
    return Collections.emptyList();
}
List<Path> files = FileUtils.listFiles(dir);
Defensive patterns

Strategy: validation

Validate before calling

public static boolean isListableDir(Path dir) {
    return Files.isDirectory(dir) && Files.isReadable(dir);
}

Try / catch

try {
    List<Path> files = FileUtils.listFiles(dir);
} catch (JadxRuntimeException e) {
    Throwable cause = e.getCause();
    if (cause instanceof NoSuchFileException) return Collections.emptyList();
    if (cause instanceof NotDirectoryException) return Collections.emptyList();
    throw e;
}

Prevention

When it happens

Trigger: Calling listFiles(dir) where dir does not exist (NoSuchFileException), where dir is a regular file rather than a directory (NotDirectoryException), or where the process lacks execute/read permission on the directory (AccessDeniedException).

Common situations: Passing an APK or JAR file path instead of its extracted directory. A race condition where the directory was deleted between an existence check and the list call. Running jadx against a path on a network share that became unavailable. Permission denied due to restrictive umask or ACL.

Related errors


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