shwenzhang/AndResGuard · error · PathNotExist
PathNotExist
Error message
PathNotExist
What it means
AbstractDirectory.getFileInput(path) resolves the path against the directory's sub-paths and file list. If the path does not resolve to a subdirectory and is not present in the files set, it throws PathNotExist (a DirectoryException) rather than returning null, signaling the caller asked for input from a file that isn't in this directory.
Solutions
- Verify the file actually exists at the expected path (ls the working directory) and check exact case-sensitive spelling.
- Ensure the decode/unpack step completed successfully before steps that call getFileInput.
- Confirm the path passed is relative to the directory root without leading slashes or '..'.
- Catch DirectoryException and re-create/decode the directory if the file is legitimately absent.
Example fix
// before
InputStream in = dir.getFileInput("Resources.arsc");
// after
String name = "resources.arsc"; // exact case as stored
if (!dir.getFiles().contains(name)) {
throw new IllegalStateException("missing " + name);
}
InputStream in = dir.getFileInput(name); Defensive patterns
Strategy: try-catch
Validate before calling
// Check membership before requesting input
String resolved = "resources.arsc";
if (!dir.getFiles().contains(resolved)) {
throw new IllegalStateException("file not present in decoded dir: " + resolved);
}
InputStream in = dir.getFileInput(resolved); Try / catch
try {
InputStream in = dir.getFileInput(path);
} catch (DirectoryException e) {
if (e.getMessage().contains("PathNotExist")) {
// re-decode the APK or recreate the directory, then retry
} else throw e;
} Prevention
- Always confirm decode/unzip completed before reading files via getFileInput.
- Use exact, case-sensitive relative paths (no leading '/', no '..').
- On Linux CI, verify filename casing matches what aapt produced.
- List dir.getFiles() in debug logs to catch path mismatches early.
When it happens
Trigger: Calling getFileInput("some/path") on an AbstractDirectory (e.g. a decoded APK directory) where the path is neither a registered subdirectory entry nor contained in getFiles() — the file was never extracted, was deleted, or the path is misnamed/wrongly cased.
Common situations: AndResGuard pipeline steps requesting files like resources.arsc or AndroidManifest.xml from a directory that was decoded incorrectly, cleaned by a previous step, or where the filename case doesn't match (Linux is case-sensitive); running steps out of order after a failed decode.
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
- the signature file do not exit. raw path=
- the old mapping file do not exit, raw path=
- Failed to obtain key with alias
- entry " " does not contain certificates
- Private key file (--key) must be specified
AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12).
Data as JSON: /api/errors/7e22e0b9b962877a.
Report an issue: GitHub.
Appendix: source
Thrown at AndResGuard-core/src/main/java/com/tencent/mm/directory/AbstractDirectory.java:98
@Override
public Map<String, Directory> getDirs() throws UnsupportedOperationException {
return getDirs(false);
}
@Override
public Map<String, Directory> getDirs(boolean recursive) throws UnsupportedOperationException {
return new LinkedHashMap<String, Directory>(getAbstractDirs(recursive));
}
@Override
public InputStream getFileInput(String path) throws DirectoryException {
SubPath subpath = getSubPath(path);
if (subpath.dir != null) {
return subpath.dir.getFileInput(subpath.path);
}
if (!getFiles().contains(subpath.path)) {
throw new PathNotExist(path);
}
return getFileInputLocal(subpath.path);
}
@Override
public OutputStream getFileOutput(String path) throws DirectoryException {
ParsedPath parsed = parsePath(path);
if (parsed.dir == null) {
getFiles().add(parsed.subpath);
return getFileOutputLocal(parsed.subpath);
}
Directory dir;
// IMPOSSIBLE_EXCEPTION
try {
dir = createDir(parsed.dir);
} catch (PathAlreadyExists e) {
dir = getAbstractDirs().get(parsed.dir);View on GitHub (pinned to e4df245d82)