MuntashirAkon/AppManager · error · IllegalArgumentException

Invalid format: isGranted not found

Error message

Invalid format: isGranted not found

What it means

NotificationListenerRule's constructor reads the isGranted boolean from the flattened rule string. If the tokenizer is exhausted, it throws this IllegalArgumentException because a NOTIFICATION rule requires the isGranted field to know whether listener access is granted.

Solutions

  1. Append a "true"/"false" isGranted token to the flattened rule string
  2. Validate token count before constructing the rule
  3. Re-export rules from the current version to restore missing fields
  4. Try-catch the parse and skip malformed notification rules

Example fix

// before
new NotificationListenerRule(pkg, "cmp", new StringTokenizer("com.example\tcmp")); // throws
// after
new NotificationListenerRule(pkg, "cmp", new StringTokenizer("com.example\tcmp\ttrue"));
Defensive patterns

Strategy: try-catch

Validate before calling

String[] p = line.split("\t");
if (p.length < 3) throw new IllegalArgumentException("NOTIFICATION rule needs isGranted");
Boolean.parseBoolean(p[2]);

Type guard

boolean isParsableNotificationRule(String line) { String[] p = line.split("\t"); return p.length >= 3 && (p[2].equals("true") || p[2].equals("false")); }

Try / catch

try { new NotificationListenerRule(pkg, name, tokenizer); } catch (IllegalArgumentException e) { log.warn("Bad notification rule: " + line); }

Prevention

When it happens

Trigger: new NotificationListenerRule(packageName, name, tokenizer) called with no tokens remaining after the name, i.e. the flattened string stops at the component name.

Common situations: Truncated rules exports, manually trimmed lines, or parsing with a wrong delimiter so the boolean token merges or disappears.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/NotificationListenerRule.java:24

import java.util.Objects;
import java.util.StringTokenizer;

import io.github.muntashirakon.AppManager.rules.RuleType;

public class NotificationListenerRule extends RuleEntry {
    private boolean mIsGranted;

    public NotificationListenerRule(@NonNull String packageName, String name, boolean isGranted) {
        super(packageName, name, RuleType.NOTIFICATION);
        this.mIsGranted = isGranted;
    }

    public NotificationListenerRule(@NonNull String packageName, String name, @NonNull StringTokenizer tokenizer) {
        super(packageName, name, RuleType.NOTIFICATION);
        if (tokenizer.hasMoreElements()) {
            mIsGranted = Boolean.parseBoolean(tokenizer.nextElement().toString());
        } else throw new IllegalArgumentException("Invalid format: isGranted not found");
    }

    public boolean isGranted() {
        return mIsGranted;
    }

    public void setGranted(boolean granted) {
        mIsGranted = granted;
    }

    @NonNull
    @Override
    public String toString() {
        return "NotificationListenerRule{" +
                "packageName='" + packageName + '\'' +
                ", name='" + name + '\'' +
                ", isGranted=" + mIsGranted +
                '}';

View on GitHub (pinned to 0152f468fc)