MuntashirAkon/AppManager · error · IllegalArgumentException
Unknown type: ${type}
Error message
Unknown type: ${type} What it means
BloatwareOption.typeToFlag() converts a bloatware type string (aosp, google, misc, oem, etc.) into its corresponding filter-list flag constant; unknown strings hit the default branch and throw IllegalArgumentException("Unknown type: " + type). It guards the mapping between type names and the static FILTER_LIST_* bit sets, and is reached from test() when the "type" key is used.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/filters/options/BloatwareOption.java:102
default:
throw new UnsupportedOperationException("Invalid key " + key);
}
}
public int typeToFlag(@NonNull String type) {
switch (type) {
case "aosp":
return FILTER_LIST_AOSP;
case "carrier":
return FILTER_LIST_CARRIER;
case "google":
return FILTER_LIST_GOOGLE;
case "misc":
return FILTER_LIST_MISC;
case "oem":
return FILTER_LIST_OEM;
default:
throw new IllegalArgumentException("Unknown type: " + type);
}
}
@NonNull
@Override
public CharSequence toLocalizedString(@NonNull Context context) {
SpannableStringBuilder sb = new SpannableStringBuilder("Bloatware");
switch (key) {
case KEY_ALL:
return sb.append(LangUtils.getSeparatorString()).append("any");
case "type":
return sb.append(" with type: ").append(flagsToString("type", intValue));
case "removal":
return sb.append(" with removal: ").append(flagsToString("removal", intValue));
default:
throw new UnsupportedOperationException("Invalid key " + key);
}
}View on GitHub (pinned to 0152f468fc)
Solutions
- Ensure the bloatware list's type field only uses recognized values ("aosp", "google", "misc", "oem", and any other mapped names)
- Add a case to typeToFlag() mapping any newly introduced type to its FILTER_LIST_* flag
- Update the app or the bloatware list definitions so both sides use the same type names
- Sanitize/pre-validate the list's type values when loading it, skipping unknown types
Example fix
// before
// bloatware.json: { "name": "Foo", "type": "vendor" } // unmapped type
boolean m = option.test(packageInfo).isMatched(); // throws
// after
// fix the list entry
// { "name": "Foo", "type": "oem" }
boolean m = option.test(packageInfo).isMatched(); Defensive patterns
Strategy: validation
Validate before calling
Set<String> KNOWN_TYPES = Set.of("aosp","google","misc","oem"); if (!KNOWN_TYPES.contains(entry.type)) { Log.warn("Skipping bloatware entry with unknown type " + entry.type); return; } Type guard
boolean isKnownBloatType(String type) { return type != null && Set.of("aosp","google","misc","oem").contains(type); } Try / catch
try { boolean matched = option.test(packageInfo).isMatched(); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Unknown type")) { matched = false; /* treat unknown type as non-matching */ } else throw e; } Prevention
- Keep bloatware list type vocabulary in sync with typeToFlag()'s mapping
- Sanitize third-party/custom bloatware lists on load
- Add a test that maps every documented type to a flag
- Handle new upstream list types in app updates promptly
When it happens
Trigger: Calling BloatwareOption with key "type" and an intValue whose matching type string (or object.type value from the bloatware list entry) is not one of the recognized names when typeToFlag() runs.
Common situations: Bloatware list JSON containing a new/renamed type not yet mapped in typeToFlag(); user-edited custom bloatware lists; version skew where the list format added types the app doesn't know.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/6278b14b2caa3239.
Report an issue: GitHub.