MuntashirAkon/AppManager · error · IllegalArgumentException
Invalid format: package names do not match.
Error message
Invalid format: package names do not match.
What it means
RuleEntry.unflattenFromString parses an external flattened rule where each part may repeat the package name. When a subsequent token differs from the package name parsed earlier, it throws this IllegalArgumentException, because all package-name parts in an external rule line must be identical.
Solutions
- Make every package-name token in the flattened string identical
- Build the flattened string programmatically from entry.getPackageName() instead of by hand
- Check that you are not swapping the field order (name vs package)
- Catch IllegalArgumentException and report the malformed line
Example fix
// before
RuleEntry.unflattenFromString("com.a\tcom.b\tPERMISSION\t...", ...); // mismatch throws
// after
RuleEntry.unflattenFromString("com.a\tcom.a\tPERMISSION\t...", ...); Defensive patterns
Strategy: validation
Validate before calling
String[] p = externalLine.split("\t");
if (p.length >= 2 && !p[0].equals(p[1]))
throw new IllegalArgumentException("package names do not match"); Type guard
boolean hasConsistentPackageNames(String line) { String[] p = line.split("\t"); return p.length < 2 || p[0].equals(p[1]); } Try / catch
try { RuleEntry.unflattenFromString(line, null); } catch (IllegalArgumentException e) { if (e.getMessage().contains("package names")) fixOrSkip(line); } Prevention
- Repeat the exact same package name in every package slot of external rules
- Build external strings programmatically from a RuleEntry instead of manually
- Check field order: package, package(optional), type, name, extras
When it happens
Trigger: Parsing a flattened string (external rule format, e.g. "pkgA\tpkgB\ttype\tname...") where the second package-name token does not equal the first, via RuleEntry.unflattenFromString or a subclass constructor.
Common situations: Hand-crafted external rule strings with a typo in the repeated package name, copy-paste mixing rules of two packages, or passing a process/component name where the package name is expected.
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
- Invalid format: packageName not found for external rule.
- Invalid format: freeze_type not found
- Invalid format: isGranted not found
- Invalid format: isGranted not found
- Invalid format: isHidden not found
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/00618100ee6021b0.
Report an issue: GitHub.
Appendix: source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/RuleEntry.java:67
@NonNull
public abstract String flattenToString(boolean isExternal);
protected String addPackageWithTab(boolean isExternal) {
return (isExternal ? packageName + "\t" : "");
}
@NonNull
public static RuleEntry unflattenFromString(@Nullable String packageName, @NonNull String ruleLine,
boolean isExternal) throws IllegalArgumentException {
StringTokenizer tokenizer = new StringTokenizer(ruleLine, "\t");
if (isExternal) {
// 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");
}View on GitHub (pinned to 0152f468fc)