MuntashirAkon/AppManager · error · org.xmlpull.v1.XmlPullParserException
Invalid tag inside <set>: ${tagName}
Error message
Invalid tag inside <set>: ${tagName} What it means
When reading a persisted StringSet shared preference (a <set> XML block), readSharedPref expects every child start tag inside <set> to be <string>. Any other tag name is a malformed persistence file, so an XmlPullParserException 'Invalid tag inside <set>' is thrown.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/sharedpref/SharedPrefsUtil.java:84
break;
case TAG_LONG:
if (attrValue != null) {
prefs.put(attrName, Long.valueOf(attrValue));
}
break;
case TAG_STRING:
prefs.put(attrName, parser.nextText());
break;
case TAG_SET:
Set<String> stringSet = new HashSet<>();
prefs.put(attrName, stringSet);
// Grab all strings
event = parser.next();
tagName = parser.getName();
while (event != XmlPullParser.END_TAG || !Objects.equals(tagName, TAG_SET)) {
if (event == XmlPullParser.START_TAG) {
if (!Objects.equals(tagName, TAG_STRING)) {
throw new XmlPullParserException("Invalid tag inside <set>: " + tagName);
}
stringSet.add(parser.nextText());
}
event = parser.next();
tagName = parser.getName();
}
break;
default:
throw new XmlPullParserException("Invalid tag: " + tagName);
}
}
event = parser.next();
}
return prefs;
}
public static void writeSharedPref(@NonNull OutputStream os, @NonNull Map<String, Object> hashMap)
throws IOException {View on GitHub (pinned to 0152f468fc)
Solutions
- Fix the XML so <set> contains only <string> children
- Validate/normalize the prefs file before parsing: reject or sanitize unknown tags inside <set>
- Re-export the preferences from the original app rather than hand-editing
- Catch XmlPullParserException in import flow and surface a clear 'malformed preferences file' error
Example fix
// before
if (!Objects.equals(tagName, TAG_STRING)) {
throw new XmlPullParserException("Invalid tag inside <set>: " + tagName);
}
// after
if (!Objects.equals(tagName, TAG_STRING)) {
Log.w(TAG, "Skipping unsupported tag inside <set>: " + tagName);
event = parser.next();
continue;
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-validate prefs XML XmlPullParser p = Xml.newPullParser(); p.setInput(reader); // walk and assert: inside <set>, every START_TAG name equals "string"
Try / catch
try {
value = SharedPrefsUtil.readSharedPref(...);
} catch (XmlPullParserException e) {
Log.w(TAG, "Malformed prefs file: " + e.getMessage());
value = defaultValue; // skip the bad <set> entry
} catch (IOException e) {
value = defaultValue;
} Prevention
- Never hand-edit exported preferences XML
- Validate imported prefs files against the expected schema before parsing
- Skip/collect unknown tags instead of failing the whole file when resilience is preferred
- Re-export from the source app if corruption is suspected
When it happens
Trigger: Parsing an exported/shared preferences XML whose <set> element contains a non-<string> child (e.g. <null/>, <int/>, or a typo'd tag), typically from hand-editing or a foreign/mismatched prefs file format.
Common situations: Importing preferences exported by another app or older version, XML edited manually inserting wrong tags, or corrupted partial writes truncated inside a <set> block.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- e
- "manifest" has duplicate "application" tags.
- Failed to load rules from misc.
- Package cannot be parsed
- {parserErrors} syntax errors during parsing and/or lexing.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/e06115ff0cf4bd3b.
Report an issue: GitHub.