MuntashirAkon/AppManager · error · PackageManager.NameNotFoundException
Package ${packageName} not found.
Error message
Package ${packageName} not found. What it means
PackageManagerCompat.getApplicationInfo calls the hidden IPackageManager.getApplicationInfo, which may return null instead of throwing. When the returned ApplicationInfo is null, this compat method throws PackageManager.NameNotFoundException("Package <name> not found.") to signal the package does not exist for that user.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/compat/PackageManagerCompat.java:295
info.providers = providers;
info.receivers = receivers;
info.permissions = permissions;
}
// Info should never be null here, but it's checked anyway.
return Objects.requireNonNull(info);
}
@SuppressWarnings("deprecation")
@NonNull
public static ApplicationInfo getApplicationInfo(String packageName, int flags, @UserIdInt int userId)
throws RemoteException, PackageManager.NameNotFoundException {
IPackageManager pm = getPackageManager();
ApplicationInfo applicationInfo;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
applicationInfo = pm.getApplicationInfo(packageName, (long) flags, userId);
} else applicationInfo = pm.getApplicationInfo(packageName, flags, userId);
if (applicationInfo == null) {
throw new PackageManager.NameNotFoundException("Package " + packageName + " not found.");
}
return applicationInfo;
}
@Nullable
public static String getInstallerPackageName(@NonNull String packageName, @UserIdInt int userId) {
try {
InstallSourceInfoCompat installSource = getInstallSourceInfo(packageName, userId);
if (installSource.getInstallingPackageName() != null) {
return installSource.getInstallingPackageName();
}
return installSource.getInitiatingPackageName();
} catch (RemoteException | SecurityException e) {
return null;
}
}
@SuppressWarnings("deprecation")View on GitHub (pinned to 0152f468fc)
Solutions
- Wrap the call in try-catch for PackageManager.NameNotFoundException.
- Verify installation first via getInstalledPackages for the target user.
- Check packageName spelling and the userId argument.
- Declare the package in <queries> for visibility if targeting API 30+.
Example fix
// before
ApplicationInfo ai = PackageManagerCompat.getApplicationInfo(pkg, 0, userId);
// after
ApplicationInfo ai = null;
try {
ai = PackageManagerCompat.getApplicationInfo(pkg, 0, userId);
} catch (PackageManager.NameNotFoundException e) {
// handle absence
} Defensive patterns
Strategy: try-catch
Validate before calling
boolean installed = getInstalledPackages(userId).stream()
.anyMatch(p -> p.packageName.equals(packageName)); Try / catch
try {
ApplicationInfo ai = PackageManagerCompat.getApplicationInfo(pkg, flags, userId);
} catch (PackageManager.NameNotFoundException e) {
ApplicationInfo ai = null;
} Prevention
- Confirm the package exists for the user
- Declare <queries> for visibility on API 30+
- Validate package name input
When it happens
Trigger: Calling getApplicationInfo(packageName, flags, userId) where the package is not installed for userId, or the binder call silently returns null (package hidden/removed).
Common situations: Querying apps on a different user profile; checking a package right after uninstall; missing package visibility (<queries> filtering) on Android 11+; querying system packages removed in newer OS builds.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Could not retrieve info for package %s with flags 0x%X for u
- 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/6bf645fe52d4bec0.
Report an issue: GitHub.