MuntashirAkon/AppManager · error · PackageManager.NameNotFoundException
Package cannot be parsed
Error message
Package cannot be parsed
What it means
For an external APK path, the ViewModel calls PackageManager.getPackageArchiveInfo(mApkPath, flags) to parse the APK's manifest. That API returns null when the archive cannot be read or its manifest is unparseable. Since the rest of the details UI needs a valid PackageInfo, the null result is converted into PackageManager.NameNotFoundException('Package cannot be parsed').
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/details/AppDetailsViewModel.java:1134
mUserId);
if (!ApplicationInfoCompat.isInstalled(mInstalledPackageInfo.applicationInfo)) {
throw new ApkFile.ApkFileException("App not installed. It only has data.");
}
} catch (Throwable e) {
Log.e(TAG, e);
mInstalledPackageInfo = null;
}
if (mExternalApk) {
// Do not get signatures via Android framework as it will simply return NULL without any clarifications.
// All signatures are fetched using PackageUtils where a fallback method is used in case the PackageInfo
// didn't load any signature. So, we should be safe from any harm.
mPackageInfo = mPackageManager.getPackageArchiveInfo(mApkPath, PackageManager.GET_PERMISSIONS
| PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS | PackageManager.GET_PROVIDERS
| PackageManager.GET_SERVICES | MATCH_DISABLED_COMPONENTS | PackageManager.GET_CONFIGURATIONS
| PackageManager.GET_SHARED_LIBRARY_FILES | PackageManager.GET_URI_PERMISSION_PATTERNS
| PackageManager.GET_META_DATA);
if (mPackageInfo == null) {
throw new PackageManager.NameNotFoundException("Package cannot be parsed");
}
if (mInstalledPackageInfo == null) {
Log.d(TAG, "%s not installed for user %d", mPackageName, mUserId);
}
mPackageInfo.applicationInfo.sourceDir = mApkPath;
mPackageInfo.applicationInfo.publicSourceDir = mApkPath;
} else {
mPackageInfo = mInstalledPackageInfo;
if (mPackageInfo == null) {
throw new PackageManager.NameNotFoundException("Package not installed");
}
}
mIsPackageExistLiveData.postValue(mIsPackageExist = true);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, e);
mIsPackageExistLiveData.postValue(mIsPackageExist = false);
} catch (Throwable e) {
Log.e(TAG, e);View on GitHub (pinned to 0152f468fc)
Solutions
- Verify the file is a plain .apk and is complete (re-download; check size/signature)
- If it's an .apks/.xapk/.apkm bundle, extract or convert it to a single base .apk first
- Confirm the path exists and is readable (SAF/permissions) before parsing
- Ensure the device platform version can parse the APK; otherwise parse with a newer framework or a library like ApkParser
Example fix
// before
File f = new File(apkPath);
viewModel.setExternalApk(f.getAbsolutePath()); // NameNotFoundException if f is .apks or corrupt
// after
File f = new File(apkPath);
if (f.getName().endsWith(".apk") && f.length() > 0 && pm.getPackageArchiveInfo(f.getAbsolutePath(), 0) != null) {
viewModel.setExternalApk(f.getAbsolutePath());
} else {
showUnparseableApkError(apkPath);
} Defensive patterns
Strategy: validation
Validate before calling
File apk = new File(apkPath);
boolean parseable = apk.isFile() && apk.length() > 0 && apk.getName().endsWith(".apk")
&& pm.getPackageArchiveInfo(apk.getAbsolutePath(), 0) != null; Type guard
boolean isPlainApk(File f) { return f.isFile() && f.getName().endsWith(".apk"); } Try / catch
try {
viewModel.setExternalApk(apkPath);
} catch (PackageManager.NameNotFoundException e) {
showError("APK is corrupt, incomplete, or a bundle (.apks/.xapk) — re-download or convert");
} Prevention
- Validate downloaded APKs (size, checksum) before import
- Convert .apks/.xapk/.apkm bundles to a base .apk first
- Check file existence/readability before parsing
- Ensure device platform supports the APK's manifest features
When it happens
Trigger: Calling setPackage/setExternalApk with an mApkPath that is not a valid APK: corrupted download, partial file, split-APK base passed incorrectly, a .apks/.xapk bundle instead of a plain .apk, a file that no longer exists at the path, or an APK whose manifest uses features the platform parser rejects.
Common situations: Importing a downloaded APK that was truncated or HTML-error-page; trying to open an app bundle (.apks/.xapk/.apkm) directly; path to APK changed or file moved after being queued; platform version too old to parse a newer APK manifest.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- "manifest" has duplicate "application" tags.
- Package cannot be parsed.
- Could not fetch package info
- Package not found.
- "manifest" tag not found.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/c3cea1407aba63f8.
Report an issue: GitHub.