{"record":{"id":"da846df4893007f0","repo":"MuntashirAkon/AppManager","slug":"invalid-format-isgranted-not-found-permissionrule","errorCode":null,"errorMessage":"Invalid format: isGranted not found","messagePattern":"Invalid format: isGranted not found","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/PermissionRule.java","lineNumber":43,"sourceCode":"\n    private boolean mIsGranted;\n    @PermissionCompat.PermissionFlags\n    private int mFlags;\n\n    public PermissionRule(@NonNull String packageName, @NonNull String permName, boolean isGranted,\n                          @PermissionCompat.PermissionFlags int flags) {\n        super(packageName, permName, RuleType.PERMISSION);\n        mIsGranted = isGranted;\n        mFlags = flags;\n        mAppOp = AppOpsManagerCompat.permissionToOpCode(name);\n    }\n\n    public PermissionRule(@NonNull String packageName, @NonNull String permName, @NonNull StringTokenizer tokenizer)\n            throws IllegalArgumentException {\n        super(packageName, permName, RuleType.PERMISSION);\n        if (tokenizer.hasMoreElements()) {\n            mIsGranted = Boolean.parseBoolean(tokenizer.nextElement().toString());\n        } else throw new IllegalArgumentException(\"Invalid format: isGranted not found\");\n        if (tokenizer.hasMoreElements()) {\n            mFlags = Integer.parseInt(tokenizer.nextElement().toString());\n        } else {\n            // Don't throw exception in order to provide backward compatibility\n            mFlags = 0;\n        }\n        mAppOp = AppOpsManagerCompat.permissionToOpCode(name);\n    }\n\n    public boolean isGranted() {\n        return mIsGranted;\n    }\n\n    public void setGranted(boolean granted) {\n        mIsGranted = granted;\n    }\n\n    @PermissionCompat.PermissionFlags","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/PermissionRule.java#L25-L61","documentation":"PermissionRule's constructor reads the isGranted boolean (and optionally flags) from the flattened rule string. If the isGranted token is absent, it throws this IllegalArgumentException; note that a missing flags token is tolerated for backward compatibility, but isGranted is mandatory.","triggerScenarios":"new PermissionRule(packageName, permName, tokenizer) invoked when the tokenizer has no token left after the permission name, i.e. the flattened PERMISSION rule line ends right after the permission.","commonSituations":"Old or hand-edited rules files lacking the isGranted field, truncated imports, or delimiter mistakes dropping the boolean token (while the missing trailing flags would have been fine).","solutions":["Add the \"true\"/\"false\" isGranted token after the permission name in the rule string","Validate that at least one token remains before constructing PermissionRule","Re-export rules with the current AppManager version","Catch IllegalArgumentException per-line during import and skip bad entries"],"exampleFix":"// before\nnew PermissionRule(pkg, \"android.permission.CAMERA\", new StringTokenizer(\"com.example\\tandroid.permission.CAMERA\")); // throws\n// after\nnew PermissionRule(pkg, \"android.permission.CAMERA\", new StringTokenizer(\"com.example\\tandroid.permission.CAMERA\\ttrue\\t0\"));","handlingStrategy":"validation","validationCode":"String[] p = line.split(\"\\t\");\nif (p.length < 3) throw new IllegalArgumentException(\"PERMISSION rule needs isGranted (flags optional)\");\nBoolean.parseBoolean(p[2]);","typeGuard":"boolean isParsablePermissionRule(String line) { String[] p = line.split(\"\\t\"); return p.length >= 3 && (p[2].equals(\"true\") || p[2].equals(\"false\")) && (p.length < 4 || p[3].matches(\"\\\\d+\")); }","tryCatchPattern":"try { new PermissionRule(pkg, perm, tokenizer); } catch (IllegalArgumentException e) { importer.report(line, e); }","preventionTips":["Remember isGranted is mandatory while flags is optional — never omit isGranted","Validate the boolean token before parsing","Diff your rules file against a fresh export to spot missing fields"],"tags":["rules-parsing","permissions","illegal-argument"],"backgroundTag":"invalid-argument-format","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}