MuntashirAkon/AppManager · error · UnsupportedOperationException
Invalid key
Error message
Invalid key ${key} What it means
LastUpdateOption.test() switches over the configured key (all/before/after); any other key hits the default branch and throws UnsupportedOperationException. Since setKeyValue() validates keys against the key map, this error means the key state and the test() switch are out of sync.
Solutions
- Add a case for the key in LastUpdateOption.test()'s switch.
- Set keys only via setKeyValue() for validation.
- Keep the key map and test() switch synchronized.
Example fix
// before
case "after":
return result.setMatched(installed && info.getLastUpdateTime() >= longValue);
default:
throw new UnsupportedOperationException("Invalid key " + key);
// after
case "after":
return result.setMatched(installed && info.getLastUpdateTime() >= longValue);
case "new_key":
return result.setMatched(/* logic */);
default:
throw new UnsupportedOperationException("Invalid key " + key); Defensive patterns
Strategy: validation
Validate before calling
if (!option.getKeysWithType().containsKey(option.getKey())) {
throw new IllegalStateException("Unrecognized key: " + option.getKey());
} Try / catch
try {
result = option.test(info, result);
} catch (UnsupportedOperationException e) {
Log.w(TAG, "Filter option key not supported", e);
result.setMatched(false);
} Prevention
- Keep LastUpdateOption's key map and test() switch in sync.
- Assign keys only via setKeyValue().
- Unit-test test() and toLocalizedString() for all keys.
When it happens
Trigger: A key in LastUpdateOption's key map without a case in test()'s switch; the protected `key` field mutated directly; stale keys from hand-built Parcels or reflection.
Common situations: Adding a new time-comparison key without updating test(); forked builds with extra keys; deserialization of crafted filter data.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Invalid key
- Invalid key
- Invalid key
- Flags must be returned by the corresponding subclasses. key
- Android System (android) cannot be backed up.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/dedbe618ae37c9dd.
Report an issue: GitHub.
Appendix: source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/filters/options/LastUpdateOption.java:46
@NonNull
@Override
public Map<String, Integer> getKeysWithType() {
return mKeysWithType;
}
@NonNull
@Override
public TestResult test(@NonNull IFilterableAppInfo info, @NonNull TestResult result) {
boolean installed = info.isInstalled();
switch (key) {
case KEY_ALL:
return result.setMatched(true);
case "before":
return result.setMatched(installed && info.getLastUpdateTime() <= longValue);
case "after":
return result.setMatched(installed && info.getLastUpdateTime() >= longValue);
default:
throw new UnsupportedOperationException("Invalid key " + key);
}
}
@NonNull
@Override
public CharSequence toLocalizedString(@NonNull Context context) {
SpannableStringBuilder sb = new SpannableStringBuilder("Last update");
switch (key) {
case KEY_ALL:
return sb.append(LangUtils.getSeparatorString()).append("any");
case "before":
return sb.append(" before ").append(DateUtils.formatDateTime(context, longValue));
case "after":
return sb.append(" after ").append(DateUtils.formatDateTime(context, longValue));
default:
throw new UnsupportedOperationException("Invalid key " + key);
}
}View on GitHub (pinned to 0152f468fc)