MuntashirAkon/AppManager · error · PackageManager.NameNotFoundException
Could not retrieve info for package %s with flags 0x%X for u
Error message
Could not retrieve info for package %s with flags 0x%X for user %d
What it means
PackageManagerCompat.getPackageInfo retries getPackageInfoInternal with major component flags (activities, services, providers, receivers, permissions) stripped. If it still returns null, the package info genuinely cannot be retrieved, so it throws PackageManager.NameNotFoundException with a formatted message including package name, stripped flags, and userId. This means the failure is not flag-related — the package is unavailable for that user.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/compat/PackageManagerCompat.java:236
@UserIdInt int userId)
throws RemoteException, PackageManager.NameNotFoundException {
PackageInfo info = null;
try {
info = getPackageInfoInternal(pm, packageName, flags, userId);
} catch (DeadObjectException e) {
Log.w(TAG, "Could not fetch info for package %s and user %d with flags 0x%X, using workaround",
e, packageName, userId, flags);
}
if (info == null) {
// The app might not be loaded properly due parcel size limit, try to load components separately.
// first check the existence of the package
int strippedFlags = flags & ~(PackageManager.GET_ACTIVITIES | PackageManager.GET_SERVICES
| PackageManager.GET_PROVIDERS | PackageManager.GET_RECEIVERS | PackageManager.GET_PERMISSIONS);
info = getPackageInfoInternal(pm, packageName, strippedFlags, userId);
if (info == null) {
// At this point, it should return package info.
// Returning null denotes that it failed again even after the major flags have been stripped.
throw new PackageManager.NameNotFoundException(String.format("Could not retrieve info for package %s with flags 0x%X for user %d",
packageName, strippedFlags, userId));
}
// Load info for major flags
ActivityInfo[] activities = null;
if ((flags & PackageManager.GET_ACTIVITIES) != 0) {
int newFlags = flags & ~(PackageManager.GET_SERVICES | PackageManager.GET_PROVIDERS
| PackageManager.GET_RECEIVERS | PackageManager.GET_PERMISSIONS);
PackageInfo info1 = getPackageInfoInternal(pm, packageName, newFlags, userId);
if (info1 != null) activities = info1.activities;
}
ServiceInfo[] services = null;
if ((flags & PackageManager.GET_SERVICES) != 0) {
int newFlags = flags & ~(PackageManager.GET_ACTIVITIES | PackageManager.GET_PROVIDERS
| PackageManager.GET_RECEIVERS | PackageManager.GET_PERMISSIONS);
PackageInfo info1 = getPackageInfoInternal(pm, packageName, newFlags, userId);
if (info1 != null) services = info1.services;
}
ProviderInfo[] providers = null;View on GitHub (pinned to 0152f468fc)
Solutions
- Catch PackageManager.NameNotFoundException and treat it as 'package unavailable for user'.
- Verify the package exists via getInstalledPackages/listing before querying with component flags.
- Check the correct userId (0 vs profile).
- Retry after a short delay if a concurrent install/update may be in progress.
Example fix
// before
PackageInfo pi = PackageManagerCompat.getPackageInfo(pm, pkg, flags, userId);
// after
PackageInfo pi;
try {
pi = PackageManagerCompat.getPackageInfo(pm, pkg, flags, userId);
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "Package unavailable: " + pkg);
pi = null;
} Defensive patterns
Strategy: try-catch
Validate before calling
boolean exists;
try { pm.getPackageInfoAsUser(pkg, 0, userId); exists = true; }
catch (PackageManager.NameNotFoundException e) { exists = false; } Try / catch
try {
PackageInfo pi = PackageManagerCompat.getPackageInfo(pm, pkg, flags, userId);
} catch (PackageManager.NameNotFoundException e) {
// treat as unavailable for user
} Prevention
- Verify package presence for the target user first
- Retry on races with install/update
- Check userId correctness
When it happens
Trigger: Calling getPackageInfo(pm, packageName, flags, userId) for a package that does not exist, is being uninstalled, or is hidden/disabled for the given user, even after retry without component flags.
Common situations: Race with an app updating/uninstalling; querying a package not visible on a managed profile; package name typo; querying hidden (suspend/hidden) packages without proper permissions.
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 ${packageName} not found.
- Package cannot be parsed.
- Package not 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/ac9d1eef45d1952b.
Report an issue: GitHub.