MuntashirAkon/AppManager · error · IllegalArgumentException

Invalid format: name not found

Error message

Invalid format: name not found

What it means

RuleEntry.unflattenFromString reads the entry name (the stub or component/permission name) as the token after the package name. If the tokenizer is exhausted at that point it throws this IllegalArgumentException, since every rule entry requires a name field before the rule type.

Solutions

  1. Include the name token (use the STUB value for package-level rules) after the package name
  2. Verify the flattened string has at least 3 tokens: packageName, name, type
  3. Re-export the rules file to restore the full format
  4. Catch IllegalArgumentException and skip malformed entries during import

Example fix

// before
RuleEntry.unflattenFromString("com.example", null); // throws: name missing
// after
RuleEntry.unflattenFromString("com.example\t__stub__\tPERMISSION\tandroid.permission.CAMERA\ttrue\t0", null);
Defensive patterns

Strategy: try-catch

Validate before calling

String[] p = line.split("\t");
if (p.length < 3) throw new IllegalArgumentException("rule needs packageName, name, and type");

Type guard

boolean hasMinimumTokens(String line) { return line.split("\t").length >= 3; }

Try / catch

try { RuleEntry.unflattenFromString(line, null); } catch (IllegalArgumentException e) { if (e.getMessage().contains("name not found")) skipTruncated(line); }

Prevention

When it happens

Trigger: Calling unflattenFromString with a string containing only the package name (single token), leaving no token for the name field.

Common situations: Truncated lines in imported rules files, hand-written strings that omit the name token, or parsing tokens consumed prematurely by custom code.

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/408cf37c8a7a94f4. Report an issue: GitHub.

Appendix: source

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

            // External rules, the first part is the package name
            if (tokenizer.hasMoreElements()) {
                // Match package name
                String newPackageName = tokenizer.nextElement().toString();
                if (packageName == null) packageName = newPackageName;
                if (!packageName.equals(newPackageName)) {
                    throw new IllegalArgumentException("Invalid format: package names do not match.");
                }
            } else throw new IllegalArgumentException("Invalid format: packageName not found for external rule.");
        }
        if (packageName == null) {
            // packageName can't be empty
            throw new IllegalArgumentException("Package name cannot be empty.");
        }
        String name;
        RuleType type;
        if (tokenizer.hasMoreElements()) {
            name = tokenizer.nextElement().toString();
        } else throw new IllegalArgumentException("Invalid format: name not found");
        if (tokenizer.hasMoreElements()) {
            try {
                type = RuleType.valueOf(tokenizer.nextElement().toString());
            } catch (Exception e) {
                throw new IllegalArgumentException("Invalid format: Invalid type");
            }
        } else throw new IllegalArgumentException("Invalid format: entryType not found");
        return getRuleEntry(packageName, name, type, tokenizer);
    }

    @NonNull
    private static RuleEntry getRuleEntry(@NonNull String packageName, @NonNull String name,
                                          @NonNull RuleType type, @NonNull StringTokenizer tokenizer)
            throws IllegalArgumentException {
        switch (type) {
            case ACTIVITY:
            case PROVIDER:
            case RECEIVER:

View on GitHub (pinned to 0152f468fc)