MuntashirAkon/AppManager · error · ApkFileException

FileNotFoundException

Error message

FileNotFoundException

What it means

Thrown when FileUtils.getFdFromUri cannot open the content URI because the target file does not exist or the provider reports it missing; the FileNotFoundException is rewrapped as ApkFileException during ApkFile construction. Faulty input: apkUri pointing to a deleted/moved file or an unopenable provider entry.

Solutions

  1. Verify the file/URI still exists before opening (it may have been deleted or moved)
  2. Re-acquire the URI via the picker if the original grant/target is gone
  3. Catch ApkFileException and inform the user the source package file is unavailable
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at app/src/main/java/io/github/muntashirakon/AppManager/apk/ApkFile.java:266 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/apk/ApkFile.java:266

                    unApkm.decryptFile(inputFD, outputStream);
                }
            } catch (IOException | RemoteException e) {
                throw new ApkFileException(e);
            }
        } else {
            // Open file descriptor if necessary
            File cacheFilePath = null;
            if (ContentResolver.SCHEME_FILE.equals(apkUri.getScheme())) {
                // File scheme may not require an FD
                cacheFilePath = new File(apkUri.getPath());
            }
            if (!FmProvider.AUTHORITY.equals(apkUri.getAuthority())) {
                // Content scheme has a third-party authority
                try {
                    mFd = FileUtils.getFdFromUri(context, apkUri, "r");
                    cacheFilePath = FileUtils.getFileFromFd(mFd);
                } catch (FileNotFoundException e) {
                    throw new ApkFileException(e);
                } catch (SecurityException e) {
                    Log.e(TAG, e);
                }
            }
            if (cacheFilePath == null || !FileUtils.canReadUnprivileged(cacheFilePath)) {
                // Cache manually
                try {
                    mCacheFilePath = mFileCache.getCachedFile(apkSource);
                } catch (IOException | SecurityException e) {
                    throw new ApkFileException("Could not cache the input file.", e);
                }
            } else mCacheFilePath = cacheFilePath;
        }
        String packageName = null;
        // Check for splits
        if (extension.equals("apk")) {
            // Get manifest attributes
            ByteBuffer manifest = getManifestFromApk(mCacheFilePath);

View on GitHub (pinned to 0152f468fc)