MuntashirAkon/AppManager · error · SecurityException
App Manager does not have the required permission
Error message
App Manager does not have the required permission
What it means
requireSelfPermission is an assertion helper: it checks whether App Manager itself holds the given permission and throws SecurityException("App Manager does not have the required permission " + permissionName) if not. It converts a soft permission check into a hard failure for operations that cannot proceed safely.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/self/SelfPermissions.java:291
}
if (uid != Process.myUid()) {
try {
return PackageManagerCompat.getPackageManager().checkUidPermission(permissionName, uid)
== PackageManager.PERMISSION_GRANTED;
} catch (RemoteException ignore) {
}
}
return checkSelfPermission(permissionName);
}
public static boolean checkSelfPermission(@NonNull String permissionName) {
return ContextCompat.checkSelfPermission(ContextUtils.getContext(), permissionName)
== PackageManager.PERMISSION_GRANTED;
}
public static void requireSelfPermission(@NonNull String permissionName) throws SecurityException {
if (!checkSelfPermission(permissionName)) {
throw new SecurityException("App Manager does not have the required permission " + permissionName);
}
}
@NonNull
public static String getCallingPackage(int callingUid) {
if (callingUid == Ops.ROOT_UID || callingUid == Ops.SHELL_UID) {
return SHELL_PACKAGE_NAME;
}
if (callingUid == Ops.SYSTEM_UID) {
return "android";
}
return BuildConfig.APPLICATION_ID;
}
}
View on GitHub (pinned to 0152f468fc)
Solutions
- Declare the permission in AndroidManifest.xml if it is a normal/install-time permission.
- Request the permission at runtime or direct the user to the special-app-access Settings screen before calling.
- Check with checkSelfPermission() first and degrade gracefully instead of asserting blindly.
- Verify on-device (adb shell appops get / dumpsys package) that the permission or op is actually granted.
Example fix
// before
SelfPermissions.requireSelfPermission(Manifest.permission.PACKAGE_USAGE_STATS);
// after
if (!SelfPermissions.checkSelfPermission(Manifest.permission.PACKAGE_USAGE_STATS)) {
// prompt user to grant Usage Access in Settings, or skip the feature
return;
}
SelfPermissions.requireSelfPermission(Manifest.permission.PACKAGE_USAGE_STATS); Defensive patterns
Strategy: try-catch
Validate before calling
boolean granted = ContextCompat.checkSelfPermission(ctx, permissionName)
== PackageManager.PERMISSION_GRANTED;
if (!granted) {
// request the grant or route the user to Settings before proceeding
} Try / catch
try {
SelfPermissions.requireSelfPermission(permissionName);
// proceed with privileged operation
} catch (SecurityException e) {
// permissionName is in e.getMessage(); request grant or disable the feature
} Prevention
- Declare every permission requireSelfPermission may assert in AndroidManifest.xml.
- For special permissions (Usage Access, etc.), guide the user to Settings instead of asserting blindly.
- Re-check permissions on every app resume; grants can be revoked anytime.
- Never call requireSelfPermission in startup paths that must not fail.
When it happens
Trigger: Calling requireSelfPermission for a permission that is not granted — not declared in the manifest, a special/AppOps permission (e.g. PACKAGE_USAGE_STATS, storage) not granted by the user, or revoked by the user or the system.
Common situations: Special permissions requiring manual grant in Settings, missing uses-permission manifest entries after refactoring, OS upgrades resetting special app-access grants, work/restricted profiles.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- Could not delete the selected backups
- Signing info verification failed.\nInstalled: ${certChecksum
- An uninstallation was necessary but couldn't perform it.
- Could not create package staging directory
- Failed to restore the KeyStore files.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/c9c51874b52a1594.
Report an issue: GitHub.