MuntashirAkon/AppManager · error · IllegalArgumentException
Display name is empty
Error message
Display name is empty
What it means
PathImpl.createDirectories() splits the sanitized display name on the file separator; when splitting yields an empty segment array (e.g. the name was only separators like "/"), it throws IllegalArgumentException("Display name is empty"). The library requires at least one concrete directory segment to create. It is a programmer error, not an environment failure.
Source
Thrown at app/src/main/java/io/github/muntashirakon/io/PathImpl.java:436
}
for (String name : dirNames) {
if (name.equals("..")) {
throw new IOException("Could not create directories in the parent directory.");
}
}
DocumentFile file = createArbitraryDirectories(documentFile, dirNames, dirNames.length);
return new PathImpl(context, file);
}
@NonNull
public Path createDirectories(@NonNull String displayName) throws IOException {
displayName = Paths.sanitize(displayName, true);
if (displayName == null) {
throw new IOException("Empty display name.");
}
String[] dirNames = displayName.split(File.separator);
if (dirNames.length == 0) {
throw new IllegalArgumentException("Display name is empty");
}
for (String name : dirNames) {
if (name.equals("..")) {
throw new IOException("Could not create directories in the parent directory.");
}
}
DocumentFile file = createArbitraryDirectories(documentFile, dirNames, dirNames.length - 1);
// Special case for the last segment
String lastSegment = dirNames[dirNames.length - 1];
Path fsRoot = VirtualFileSystem.getFsRoot(Paths.appendPathSegment(file.getUri(), lastSegment));
DocumentFile t = fsRoot != null ? fsRoot.documentFile : file.findFile(lastSegment);
if (t != null) {
throw new IOException(t.getUri() + " already exists.");
}
t = file.createDirectory(lastSegment);
if (t == null) {
throw new IOException("Directory" + file.getUri() + File.separator + lastSegment + " could not be created.");
}View on GitHub (pinned to 0152f468fc)
Solutions
- Pass a concrete relative directory name without leading/trailing slashes, e.g. "foo/bar" instead of "/foo/bar/".
- Strip leading/trailing File.separator from the input before calling createDirectories.
- Validate that the trimmed name is non-empty and contains at least one non-separator character before calling.
- Split the path yourself and call createDirectories per-level if you need root-relative handling.
Example fix
// before
path.createDirectories("/mydir/"); // IllegalArgumentException: Display name is empty
// after
String name = "/mydir/".replaceAll("^/+|/+$", "");
if (!name.isEmpty()) path.createDirectories(name); Defensive patterns
Strategy: validation
Validate before calling
String name = raw == null ? "" : raw.replaceAll("^"+File.separator+"+|"+File.separator+"+$", "");
if (name.isEmpty() || name.split(File.separator).length == 0) throw new IllegalArgumentException("Need at least one directory segment"); Type guard
boolean isCreatableDirName(String n) { return n != null && !n.replaceAll("^/+|/+$", "").isEmpty(); } Try / catch
try { path.createDirectories(name); } catch (IllegalArgumentException e) { log.warn("Rejecting empty dir name", e); } Prevention
- Never pass absolute or slash-delimited-with-empty-segments names
- Trim separators before calling
- Build names with Paths.appendPathSegment instead of string concat
When it happens
Trigger: Calling createDirectories with a name that sanitizes to only path separators, e.g. "/" or "//", so displayName.split(File.separator) produces zero usable segments.
Common situations: Building the directory name by joining path components with a separator and passing the result including a trailing/leading slash; concatenating an empty variable into a path string; passing a URI path portion instead of a display name.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Display name contains file separator.
- Couldn't find any writable Obb dir
- Could not delete the selected backups
- Data directory cannot be empty.
- Could not create package staging directory
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/c3d4f696690541a7.
Report an issue: GitHub.