MuntashirAkon/AppManager · error · IllegalArgumentException

Invalid type=

Error message

Invalid type=

What it means

getRuleEntry dispatches on the parsed RuleType to construct the concrete RuleEntry subclass. If the switch sees a RuleType with no corresponding case (default branch), it throws IllegalArgumentException("Invalid type=" + type.name()). With exhaustive enums this normally means a new RuleType was added without updating the factory.

Solutions

  1. Upgrade App Manager so the factory handles the RuleType named in the message.
  2. Remove or migrate rules using the unsupported type before importing.
  3. If you maintain a fork, add a case for the missing RuleType in getRuleEntry.

Example fix

// before (older factory)
case FREEZE: return new FreezeRule(packageName, tokenizer);
// after
case FREEZE: return new FreezeRule(packageName, tokenizer);
case NEW_TYPE: return new NewTypeRule(packageName, tokenizer);
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the RuleType is one handled by the installed build:
Set<RuleType> supported = Set.of(RuleType.ACTIVITY, RuleType.PROVIDER, RuleType.RECEIVER,
    RuleType.SERVICE, RuleType.APP_OP, RuleType.PERMISSION, RuleType.MAGISK_HIDE,
    RuleType.MAGISK_DENY_LIST, RuleType.BATTERY_OPT, RuleType.NET_POLICY,
    RuleType.NOTIFICATION, RuleType.URI_GRANT, RuleType.SSAID, RuleType.FREEZE);

Try / catch

try {
    RuleEntry e = RuleEntry.unflattenFromString(pkg, line, true);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Invalid type=")) {
        upgradeAppOrSkipRule(line);
    }
}

Prevention

When it happens

Trigger: Parsing a rule whose type maps to a RuleType constant that getRuleEntry does not handle (e.g. a newly added enum constant on a newer data file parsed by an older build).

Common situations: Downgrade: rules exported by a newer App Manager imported into an older version; a fork with an extended RuleType; database contents edited to hold an unhandled type.

Related errors


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

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/RuleEntry.java:121

                return new PermissionRule(packageName, name, tokenizer);
            case MAGISK_HIDE:
                return new MagiskHideRule(packageName, name, tokenizer);
            case MAGISK_DENY_LIST:
                return new MagiskDenyListRule(packageName, name, tokenizer);
            case BATTERY_OPT:
                return new BatteryOptimizationRule(packageName, tokenizer);
            case NET_POLICY:
                return new NetPolicyRule(packageName, tokenizer);
            case NOTIFICATION:
                return new NotificationListenerRule(packageName, name, tokenizer);
            case URI_GRANT:
                return new UriGrantRule(packageName, tokenizer);
            case SSAID:
                return new SsaidRule(packageName, tokenizer);
            case FREEZE:
                return new FreezeRule(packageName, tokenizer);
            default:
                throw new IllegalArgumentException("Invalid type=" + type.name());
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof RuleEntry)) return false;
        RuleEntry ruleEntry = (RuleEntry) o;
        return name.equals(ruleEntry.name) && packageName.equals(ruleEntry.packageName) && type == ruleEntry.type;
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, packageName, type);
    }
}

View on GitHub (pinned to 0152f468fc)