MuntashirAkon/AppManager · error · IllegalArgumentException
Invalid format: uriGrant not found
Error message
Invalid format: uriGrant not found
What it means
The UriGrantRule constructor reads the URI-grant payload from the tokenizer and passes it to UriManager.UriGrant.unflattenFromString. If no token remains, it throws IllegalArgumentException("Invalid format: uriGrant not found") because a URI grant rule requires the grant descriptor.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/UriGrantRule.java:26
import java.util.StringTokenizer;
import io.github.muntashirakon.AppManager.rules.RuleType;
import io.github.muntashirakon.AppManager.uri.UriManager;
public class UriGrantRule extends RuleEntry {
@NonNull
private final UriManager.UriGrant mUriGrant;
public UriGrantRule(@NonNull String packageName, @NonNull UriManager.UriGrant uriGrant) {
super(packageName, STUB, RuleType.URI_GRANT);
mUriGrant = uriGrant;
}
public UriGrantRule(@NonNull String packageName, @NonNull StringTokenizer tokenizer) {
super(packageName, STUB, RuleType.URI_GRANT);
if (tokenizer.hasMoreElements()) {
mUriGrant = UriManager.UriGrant.unflattenFromString(tokenizer.nextElement().toString());
} else throw new IllegalArgumentException("Invalid format: uriGrant not found");
}
@NonNull
public UriManager.UriGrant getUriGrant() {
return mUriGrant;
}
@NonNull
@Override
public String toString() {
return "UriGrantRule{" +
"packageName='" + packageName + '\'' +
", uriGrant=" + mUriGrant +
'}';
}
@NonNull
@OverrideView on GitHub (pinned to 0152f468fc)
Solutions
- Append the flattened UriGrant field to the rule line.
- Pre-check token count (>=4) for URI_GRANT rules before parsing and skip invalid lines.
- Re-export rules from the originating device.
Example fix
// before String line = pkg + "\tSTUB\tURI_GRANT"; // after String line = pkg + "\tSTUB\tURI_GRANT\t" + uriGrant.flattenToString();
Defensive patterns
Strategy: validation
Validate before calling
String[] p = line.split("\t", -1);
boolean ok = "URI_GRANT".equals(p[2]) ? p.length >= 4 : true;
// only parse when ok Try / catch
try {
RuleEntry e = RuleEntry.unflattenFromString(null, line, false);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("uriGrant not found")) repairOrSkip(line);
} Prevention
- Always include the flattened UriGrant token when writing URI_GRANT rules.
- Validate rules files with a dry-run parse before applying.
When it happens
Trigger: Parsing "pkg\tSTUB\tURI_GRANT" without a fourth tab-separated token containing the flattened UriGrant.
Common situations: Truncated or hand-edited rules file; a flattened uriGrant string that failed upstream parsing is a different failure; here it is simply absent.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Invalid format: entryType not found
- Invalid format: ssaid not found
- Invalid format: mode not found
- Invalid format: enabled not found
- Invalid format: componentStatus not found
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/94c495ac2df31c2b.
Report an issue: GitHub.