MuntashirAkon/AppManager · error · PackageManager.NameNotFoundException
Package not found.
Error message
Package not found.
What it means
loadInstalledPackageInfo throws PackageManager.NameNotFoundException("Package not found.") when getPackageInfo() returns null for the given package name despite querying with MATCH_UNINSTALLED_PACKAGES and MATCH_DISABLED_COMPONENTS. This means no installed (or recently uninstalled-but-still-cached) package matches the name on this user/profile. It is thrown when building PackageInstaller metadata for an already-installed target app.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/apk/installer/PackageInstallerViewModel.java:484
private synchronized void persistInstallResult() {
if (mInstallResult != null) {
mSavedStateHandle.set(STATE_INSTALL_RESULT, mInstallResult);
} else {
mSavedStateHandle.remove(STATE_INSTALL_RESULT);
}
}
@WorkerThread
@NonNull
private PackageInfo loadInstalledPackageInfo(String packageName) throws PackageManager.NameNotFoundException {
@SuppressLint("WrongConstant")
PackageInfo packageInfo = mPm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS
| PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS | PackageManager.GET_PROVIDERS
| PackageManager.GET_SERVICES | MATCH_DISABLED_COMPONENTS | GET_SIGNING_CERTIFICATES | MATCH_UNINSTALLED_PACKAGES
| PackageManager.GET_CONFIGURATIONS | PackageManager.GET_SHARED_LIBRARY_FILES);
if (packageInfo == null) {
throw new PackageManager.NameNotFoundException("Package not found.");
}
return packageInfo;
}
}
View on GitHub (pinned to 0152f468fc)
Solutions
- Confirm the exact applicationId via `adb shell pm list packages | grep <name>` on the same device/user.
- Resolve the correct UserHandle and call getPackageInfoAsUser instead of the default-user variant.
- Re-check installation status immediately before the call and handle uninstalled packages gracefully.
- Account for build-type suffixes (debug/release applicationIdSuffix) when constructing the package name.
- Catch NameNotFoundException and surface a clear 'app not installed' message instead of crashing.
Example fix
// before
PackageInfo pi = mPm.getPackageInfo(packageName, flags);
if (pi == null) throw new PackageManager.NameNotFoundException("Package not found.");
// after
PackageInfo pi;
try {
pi = mPm.getPackageInfo(packageName, flags);
} catch (PackageManager.NameNotFoundException e) {
throw new PackageManager.NameNotFoundException(
"Package not found for current user: " + packageName);
}
if (pi == null) throw new PackageManager.NameNotFoundException("Package not found: " + packageName); Defensive patterns
Strategy: try-catch
Validate before calling
boolean installed = getPackageManager().getInstalledPackages(0).stream()
.anyMatch(p -> p.packageName.equals(packageName)); Try / catch
try {
PackageInfo pi = mPm.getPackageInfo(packageName, flags);
} catch (PackageManager.NameNotFoundException e) {
showUserVisibleError("Target app " + packageName + " is not installed on this user profile");
} Prevention
- Always resolve package names via PackageManager at call time, never cache them.
- Handle multi-user/work-profile cases by resolving the right UserHandle.
- Double-check applicationIdSuffix for debug builds.
- Treat NameNotFoundException as an expected condition in installer flows, not a crash.
When it happens
Trigger: loadPackageInfo -> loadInstalledPackageInfo is called with a packageName that is not installed: wrong applicationId, app uninstalled, querying a different user/profile, package only present in another work profile, or app removed between the listing and this call.
Common situations: Stale package name after an app was renamed/uninstalled, querying without the right user handle (UserManager profiles), app rejected or uninstalled after installer launched, or applicationId suffix (e.g. .debug) differing from the expected name.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Package cannot be parsed.
- Package name is missing.
- No base backup found.
- Apparently the install wasn't complete in the previous secti
- Could not fetch package info
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/9596896e9511f9b0.
Report an issue: GitHub.