MuntashirAkon/AppManager · error · FileNotFoundException

Class definition for + src.getFullPath() + is not found.

Error message

Class definition for + src.getFullPath() + is not found.

What it means

ApkFileSystem.cacheFile extracts a class/dex entry from a mounted APK by writing the corresponding LocalFileRecord to a sink file. The Node's CentralDirectoryRecord is null (or the APK/sections handle is closed), so the entry cannot be located in the APK's central directory; a FileNotFoundException naming the node's full path is thrown.

Source

Thrown at app/src/main/java/io/github/muntashirakon/io/fs/ApkFileSystem.java:180

        //noinspection RedundantIfStatement
        if (access == OsConstants.R_OK) {
            return true;
        }
        // X_OK, R_OK|X_OK, W_OK, R_OK|W_OK, R_OK|W_OK|X_OK are false
        return false;
    }

    @NonNull
    @Override
    protected InputStream getInputStream(@NonNull Node<?> node) throws IOException {
        return new FileInputStream(getCachedFile(node, false));
    }

    @Override
    protected void cacheFile(@NonNull Node<?> src, @NonNull File sink) throws IOException {
        CentralDirectoryRecord cdRecord = (CentralDirectoryRecord) src.getObject();
        if (cdRecord == null || mApk == null || mApkSections == null) {
            throw new FileNotFoundException("Class definition for " + src.getFullPath() + " is not found.");
        }
        DataSource lfhSection = mApk.slice(0, mApkSections.getZipCentralDirectoryOffset());
        try (FileOutputStream os = new FileOutputStream(sink)) {
            DataSink out = DataSinks.asDataSink(os);
            LocalFileRecord.outputUncompressedData(lfhSection, cdRecord, lfhSection.size(), out);
        } catch (ZipFormatException e) {
            throw new IOException(e);
        }
    }

    @NonNull
    private static Node<CentralDirectoryRecord> buildTree(@NonNull List<CentralDirectoryRecord> cdRecords) {
        Node<CentralDirectoryRecord> rootNode = new Node<>(null, File.separator);
        rootNode.addExtra("mtime", System.currentTimeMillis());
        for (CentralDirectoryRecord cdRecord : cdRecords) {
            buildTree(rootNode, cdRecord);
        }
        return rootNode;

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Verify the class entry actually exists in the APK before accessing it (list entries / check the path spelling, it is case-sensitive).
  2. Remount the APK filesystem so Node objects and central-directory records are refreshed against the current APK.
  3. Do not use the filesystem after unmount/close; re-mount and obtain fresh Nodes.
  4. Catch FileNotFoundException and re-check node.getObject() != null before copying.

Example fix

// before
vfs.copy(node, cacheFile);
// after
if (node.getObject() == null) {
    vfs = VirtualFileSystem.remount(apkUri, options); // refresh records
    node = vfs.getNode(node.getFullPath());
}
vfs.copy(node, cacheFile);
Defensive patterns

Strategy: try-catch

Validate before calling

if (node.getObject() == null) throw new FileNotFoundException("Missing APK entry: " + node.getFullPath());

Type guard

static boolean hasApkRecord(Node<?> n) { return n.getObject() instanceof CentralDirectoryRecord; }

Try / catch

try {
    vfs.cacheFile(node, sink);
} catch (FileNotFoundException e) {
    // remount APK and retry once, else skip entry
}

Prevention

When it happens

Trigger: Copying/caching a file from an APK-backed VirtualFileSystem when node.getObject() (CentralDirectoryRecord) is null, or mApk/mApkSections were never initialized or have been released (filesystem closed/unmounted).

Common situations: Accessing an APK mount after the underlying APK was updated/re-signed so cached records are stale; using the VFS after close(); malformed or split APKs where the entry is missing from the central directory.

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


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/d7544ec547eaaaa5. Report an issue: GitHub.