MuntashirAkon/AppManager · error · IllegalArgumentException
Invalid format: mode not found
Error message
Invalid format: mode not found
What it means
AppOpRule parses a TSV rule line: the op code comes from opInt, and the mode must be the next token in the StringTokenizer. If the token stream is exhausted, the rule line is malformed and the constructor throws IllegalArgumentException('Invalid format: mode not found').
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/AppOpRule.java:30
public class AppOpRule extends RuleEntry {
private final int mOp;
@AppOpsManagerCompat.Mode
private int mMode;
public AppOpRule(@NonNull String packageName, int op, @AppOpsManagerCompat.Mode int mode) {
super(packageName, String.valueOf(op), RuleType.APP_OP);
mOp = op;
mMode = mode;
}
public AppOpRule(@NonNull String packageName, String opInt, @NonNull StringTokenizer tokenizer)
throws RuntimeException {
super(packageName, opInt, RuleType.APP_OP);
mOp = Integer.parseInt(opInt);
if (tokenizer.hasMoreElements()) {
mMode = Integer.parseInt(tokenizer.nextElement().toString());
} else throw new IllegalArgumentException("Invalid format: mode not found");
}
public int getOp() {
return mOp;
}
@AppOpsManagerCompat.Mode
public int getMode() {
return mMode;
}
public void setMode(@AppOpsManagerCompat.Mode int mode) {
mMode = mode;
}
@NonNull
@Override
public String toString() {View on GitHub (pinned to 0152f468fc)
Solutions
- Fix the rule source so each APP_OP line has: package, op code, and mode (e.g. pkg<TAB>op<TAB>mode)
- Validate token count before constructing, or catch IllegalArgumentException per line and skip malformed rows
- Re-export the rules from a current App Manager version to regenerate well-formed lines
Example fix
// before
AppOpRule rule = new AppOpRule(pkg, opInt, new StringTokenizer(line, "\t"));
// after
StringTokenizer st = new StringTokenizer(line, "\t");
if (st.countTokens() < 2) {
Log.w(TAG, "Skipping malformed app-op line: " + line);
return;
}
AppOpRule rule = new AppOpRule(pkg, opInt, st); Defensive patterns
Strategy: validation
Validate before calling
StringTokenizer st = new StringTokenizer(line, "\t");
if (st.countTokens() < 3) { // package + op + mode
Log.w(TAG, "Malformed APP_OP line: " + line);
return;
} Try / catch
try {
rule = new AppOpRule(pkg, opInt, tokenizer);
} catch (IllegalArgumentException e) {
Log.w(TAG, "Skipping invalid app-op rule: " + line, e);
} Prevention
- Validate column count per TSV line before constructing rules
- Keep rule files generated by the same app version that will import them
- Never hand-edit exported TSV backups; re-export instead
When it happens
Trigger: Constructing AppOpRule with a tokenizer that has no remaining element — i.e. an app-op rule line containing only the package and op code without a mode field.
Common situations: Hand-edited or truncated rules backup TSV files; importing rules exported by an older App Manager version with a different line format; copy-paste dropping the last column.
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: enabled not found
- Invalid format: componentStatus not found
- Failed to load rules from misc.
- Invalid format: Invalid type
- Invalid format: entryType not found
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/57f45f7c5035826c.
Report an issue: GitHub.