MuntashirAkon/AppManager · error · RemoteException

Missing required permission…

Error message

Missing required permission: android.permission.MANAGE_USERS.

What it means

hidePackage only proceeds when the caller can act as a package-hiding mechanism (shell/root or the matching hidden-API path); otherwise it throws RemoteException("Missing required privilege: android.permission.MANAGE_USERS") because the OS enforces that privilege for hiding packages. It is a permission gate, not a package lookup failure.

Solutions

  1. Grant/hold android.permission.MANAGE_USERS (privileged/system app) or run via shell/root.
  2. Use non-privileged alternatives (setApplicationHiddenEnabled via device owner, or just uninstall/disable).
  3. Catch RemoteException and degrade gracefully (e.g. inform the user the action requires elevated permissions).
  4. Check permission availability before invoking hidePackage.

Example fix

// before
PackageManagerCompat.hidePackage(pkg, true, userId);
// after
if (ContextCompat.checkSelfPermission(ctx, "android.permission.MANAGE_USERS")
        == PackageManager.PERMISSION_GRANTED) {
    PackageManagerCompat.hidePackage(pkg, true, userId);
} else {
    throw new SecurityException("MANAGE_USERS required");
}
Defensive patterns

Strategy: try-catch

Validate before calling

boolean canHide = ContextCompat.checkSelfPermission(ctx,
        "android.permission.MANAGE_USERS") == PackageManager.PERMISSION_GRANTED;

Try / catch

try {
    PackageManagerCompat.hidePackage(pkg, hidden, userId);
} catch (RemoteException e) {
    // inform user that elevated permission is required
}

Prevention

When it happens

Trigger: Calling PackageManagerCompat.hidePackage(packageName, hidden, userId) without holding android.permission.MANAGE_USERS (and typically without shell/root or a system-signature), so the fallback branch throws.

Common situations: Running in a normal app sandbox without privileged perms; device owner not configured; testing hide/unhide features on a non-rooted device.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/a1f59ea8ad6d56e6. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/compat/PackageManagerCompat.java:491

        }
        return false;
    }

    @RequiresPermission(ManifestCompat.permission.MANAGE_USERS)
    public static void hidePackage(String packageName, @UserIdInt int userId, boolean hide) throws RemoteException {
        if (SelfPermissions.checkSelfOrRemotePermission(ManifestCompat.permission.MANAGE_USERS)) {
            boolean hidden = getPackageManager().setApplicationHiddenSettingAsUser(packageName, hide, userId);
            if (userId != UserHandleHidden.myUserId()) {
                if (hidden) {
                    if (hide) {
                        BroadcastUtils.sendPackageRemoved(ContextUtils.getContext(), new String[]{packageName});
                    } else {
                        BroadcastUtils.sendPackageAdded(ContextUtils.getContext(), new String[]{packageName});
                    }
                }
            }
        } else {
            throw new RemoteException("Missing required permission: android.permission.MANAGE_USERS.");
        }
    }

    public static boolean isPackageHidden(String packageName, @UserIdInt int userId) throws RemoteException {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            try {
                // Find using private flags
                ApplicationInfo info = getApplicationInfo(packageName,
                        PackageManagerCompat.MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, userId);
                return ApplicationInfoCompat.isHidden(info);
            } catch (PackageManager.NameNotFoundException ignore) {
            }
        }
        if (SelfPermissions.checkSelfOrRemotePermission(ManifestCompat.permission.MANAGE_USERS)) {
            return getPackageManager().getApplicationHiddenSettingAsUser(packageName, userId);
        }
        // Otherwise, there is no way to detect if the package is hidden
        return false;

View on GitHub (pinned to 0152f468fc)