MuntashirAkon/AppManager · error · IllegalArgumentException
Invalid export type: {exportType}
Error message
Invalid export type: {exportType} What it means
ListExporter.export throws IllegalArgumentException("Invalid export type: " + exportType) when the exportType passed to export() is not one of the handled constants (e.g. XML, Markdown, and any other supported switch cases). The switch statement falls through to the default throw, guarding against unsupported enum/int values. This is a programmer/API-contract error, not a runtime condition.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/apk/list/ListExporter.java:71
switch (exportType) {
case EXPORT_TYPE_CSV:
exportCsv(writer, appListItems);
return;
case EXPORT_TYPE_JSON:
try {
exportJson(writer, appListItems);
} catch (JSONException e) {
ExUtils.rethrowAsIOException(e);
}
return;
case EXPORT_TYPE_XML:
exportXml(writer, appListItems);
return;
case EXPORT_TYPE_MARKDOWN:
exportMarkdown(context, writer, appListItems);
return;
}
throw new IllegalArgumentException("Invalid export type: " + exportType);
}
private static void exportXml(@NonNull Writer writer,
@NonNull List<AppListItem> appListItems) throws IOException {
XmlSerializer xmlSerializer = Xml.newSerializer();
xmlSerializer.setOutput(writer);
xmlSerializer.startDocument("UTF-8", true);
xmlSerializer.docdecl("packages SYSTEM \"https://raw.githubusercontent.com/MuntashirAkon/AppManager/master/schema/packages.dtd\"");
xmlSerializer.startTag("", "packages");
xmlSerializer.attribute("", "version", String.valueOf(1));
for (AppListItem appListItem : appListItems) {
xmlSerializer.startTag("", "package");
xmlSerializer.attribute("", "name", appListItem.packageName);
xmlSerializer.attribute("", "label", appListItem.getPackageLabel());
xmlSerializer.attribute("", "versionCode", String.valueOf(appListItem.getVersionCode()));
xmlSerializer.attribute("", "versionName", appListItem.getVersionName());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
xmlSerializer.attribute("", "minSdk", String.valueOf(appListItem.getMinSdk()));View on GitHub (pinned to 0152f468fc)
Solutions
- Pass one of the supported ListExporter.EXPORT_TYPE_* constants instead of a raw int.
- Validate the exportType against the supported set before calling export().
- If the value comes from saved preferences, re-migrate/reset it to a valid constant.
- Update the library/copy of ListExporter so the switch handles the type you are using.
Example fix
// before
int type = prefs.getInt("export_type", -1);
ListExporter.export(context, writer, items, type);
// after
int type = prefs.getInt("export_type", ListExporter.EXPORT_TYPE_XML);
if (type != ListExporter.EXPORT_TYPE_XML && type != ListExporter.EXPORT_TYPE_MARKDOWN) {
type = ListExporter.EXPORT_TYPE_XML;
}
ListExporter.export(context, writer, items, type); Defensive patterns
Strategy: validation
Validate before calling
int[] SUPPORTED = {ListExporter.EXPORT_TYPE_XML, ListExporter.EXPORT_TYPE_MARKDOWN};
boolean ok = Arrays.stream(SUPPORTED).anyMatch(t -> t == exportType);
if (!ok) throw new IllegalArgumentException("Unsupported export type: " + exportType); Type guard
static boolean isSupportedExportType(int t) {
return t == ListExporter.EXPORT_TYPE_XML || t == ListExporter.EXPORT_TYPE_MARKDOWN;
} Try / catch
try {
ListExporter.export(context, writer, items, exportType);
} catch (IllegalArgumentException e) {
Log.w(TAG, "Unknown export type, defaulting to XML", e);
ListExporter.export(context, writer, items, ListExporter.EXPORT_TYPE_XML);
} Prevention
- Only reference ListExporter.EXPORT_TYPE_* constants, never raw ints.
- When loading the type from preferences, validate and clamp to known constants.
- Keep constant lists in sync when adding new export formats to the switch.
- Prefer an enum with values() validation over scattered int constants.
When it happens
Trigger: Calling ListExporter.export(context, writer, appListItems, exportType) with an exportType value outside the supported set of EXPORT_TYPE_* constants — e.g. an uninitialized value, -1, or a constant removed in this version.
Common situations: Passing a new EXPORT_TYPE constant added upstream but not handled in an older copy of ListExporter, reading the type from preferences as a raw int/string that no longer maps to a constant, or mixing constants from another exporter class.
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
- Content provider has crashed.
- Unknown mode of operation: ${newMode}
- Invalid type + type
- "manifest" has duplicate "application" tags.
- Couldn't find any writable Obb dir
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/113f10a67447cf0f.
Report an issue: GitHub.