MuntashirAkon/AppManager · error · FileNotFoundException
Cannot find
Error message
Cannot find
What it means
PathImpl.findFile(displayName) throws FileNotFoundException("Cannot find <this>/<displayName>") when findFileInternal locates no child with that name under the current path. It is a strict lookup: unlike findOrCreateFile, it never creates the entry. The message embeds the full attempted path.
Source
Thrown at app/src/main/java/io/github/muntashirakon/io/PathImpl.java:472
}
return new PathImpl(context, t);
}
@Nullable
public Path getParent() {
DocumentFile file = getRealDocumentFile(documentFile).getParentFile();
return file == null ? null : new PathImpl(context, file);
}
public boolean hasFile(@NonNull String displayName) {
return findFileInternal(documentFile, displayName) != null;
}
@NonNull
public Path findFile(@NonNull String displayName) throws FileNotFoundException {
DocumentFile nextPath = findFileInternal(documentFile, displayName);
if (nextPath == null) {
throw new FileNotFoundException("Cannot find " + this + File.separatorChar + displayName);
}
return new PathImpl(context, nextPath);
}
@NonNull
public Path findOrCreateFile(@NonNull String displayName, @Nullable String mimeType) throws IOException {
displayName = Paths.sanitize(displayName, true);
if (displayName == null) {
throw new IOException("Empty display name.");
}
if (displayName.indexOf(File.separatorChar) != -1) {
throw new IllegalArgumentException("Display name contains file separator.");
}
DocumentFile documentFile = getRealDocumentFile(this.documentFile);
if (!documentFile.isDirectory()) {
throw new IOException("Current file is not a directory.");
}
String extension = null;View on GitHub (pinned to 0152f468fc)
Solutions
- Check hasFile(displayName) first and handle absence gracefully.
- Use findOrCreateFile if the file should be created when missing.
- Include the correct extension in displayName, or resolve the exact name by listing children.
- Catch FileNotFoundException and fall back to scanning the directory for a case-insensitive match.
Example fix
// before
Path p = path.findFile("config.json"); // FileNotFoundException
// after
Path p = path.hasFile("config.json") ? path.findFile("config.json") : path.findOrCreateFile("config", "application/json"); Defensive patterns
Strategy: try-catch
Validate before calling
if (!path.hasFile(displayName)) { /* handle absence before lookup */ } Try / catch
try {
return path.findFile(name);
} catch (FileNotFoundException e) {
return path.findOrCreateFile(baseName, mime); // create-or-fallback
} Prevention
- Prefer hasFile() for existence probes
- Include the real extension in lookups
- Re-list directory contents after external changes
When it happens
Trigger: Calling findFile with a name that does not exist as a direct child — wrong name, wrong case, missing extension, or the entry lives in a different directory.
Common situations: Assuming files persist after app-data clear or reinstall; name-case mismatch (SAF can be case-sensitive depending on provider); looking up "notes" when the actual file is "notes.txt"; stale cache of file names.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Class definition for + src.getFullPath() + is not found.
- Class definition for + node.getFullPath() + is not found.
- Class definition for + src.getFullPath() + is not found.
- Error! %s could not be found or copied.\n
- Couldn't find any writable Obb dir
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/ce93a2b903bb6a5a.
Report an issue: GitHub.