MuntashirAkon/AppManager · error · ApkFile.ApkFileException
"manifest" has duplicate "application" tags.
Error message
"manifest" has duplicate "application" tags.
What it means
ApkUtils.getManifestAttributes parses the binary AndroidManifest.xml of an APK and expects exactly one <application> element under the root <manifest>. When a second <application> element is found (the iterator still has more entries after the first), it throws ApkFile.ApkFileException. A well-formed APK can only declare one application tag; duplicates indicate a malformed or tampered manifest.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/apk/ApkUtils.java:247
Iterator<ResXmlAttribute> attrIt = resManifestElement.getAttributes();
ResXmlAttribute attr;
String attrName;
while (attrIt.hasNext()) {
attr = attrIt.next();
attrName = attr.getName();
if (TextUtils.isEmpty(attrName)) {
continue;
}
manifestAttrs.put(attrName, attr.getValueAsString());
}
// application
ResXmlElement resApplicationElement = null;
Iterator<ResXmlElement> resXmlElementIt = resManifestElement.getElements("application");
if (resXmlElementIt.hasNext()) {
resApplicationElement = resXmlElementIt.next();
}
if (resXmlElementIt.hasNext()) {
throw new ApkFile.ApkFileException("\"manifest\" has duplicate \"application\" tags.");
}
if (resApplicationElement == null) {
Log.w(TAG, "No application tag found while parsing APK.");
return manifestAttrs;
}
attrIt = resApplicationElement.getAttributes();
while (attrIt.hasNext()) {
attr = attrIt.next();
attrName = attr.getName();
if (TextUtils.isEmpty(attrName)) {
continue;
}
if (manifestAttrs.containsKey(attrName)) {
Log.w(TAG, "Ignoring invalid attribute in the application tag: " + attrName);
continue;
}
manifestAttrs.put(attrName, attr.getValueAsString());
}View on GitHub (pinned to 0152f468fc)
Solutions
- Verify the APK's AndroidManifest.xml with aapt dump badging or apkanalyzer to confirm duplicate <application> tags.
- Rebuild the APK with a correct single <application> element (fix the manifest merger / build config).
- If merging splits, use a merge tool that deduplicates the application tag instead of concatenating manifests.
- Wrap the call in try-catch for ApkFile.ApkFileException and reject the APK as malformed.
Example fix
// before
Map<String, String> attrs = ApkUtils.getManifestAttributes(apkFile);
// after
try {
Map<String, String> attrs = ApkUtils.getManifestAttributes(apkFile);
} catch (ApkFile.ApkFileException e) {
throw new IOException("Malformed APK: " + e.getMessage(), e);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check: count application elements before full parse
int appTags = Collections.list(manifestElement.getElements("application")).size();
if (appTags != 1) throw new IOException("Expected 1 application tag, found " + appTags); Try / catch
try {
Map<String, String> attrs = ApkUtils.getManifestAttributes(apkFile);
} catch (ApkFile.ApkFileException e) {
Log.e(TAG, "Malformed manifest: duplicate application tag", e);
} Prevention
- Only parse APKs built by trusted toolchains; reject repackaged/merged APKs up front.
- Sanity-check manifests with aapt dump badging before programmatic parsing.
- Treat manifest exceptions as a signal the APK is tampered or corrupt and quarantine it.
When it happens
Trigger: Calling ApkUtils.getManifestAttributes on an APK whose binary AndroidManifest.xml contains two or more <application> elements. Typically occurs when analyzing manually rebuilt, patched, or re-compiled APKs where manifest merging produced duplicate application tags.
Common situations: Inspecting APKs produced by broken merge tools, maliciously repackaged APKs, or APKs assembled by concatenating manifests (e.g. improper split-APK merging or smali re-build toolchains).
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
- "manifest" tag not found.
- "manifest" does not have required attribute "package".
- Package cannot be parsed
- Failed to read AndroidManifest.xml
- Missing {MANIFEST_FILE}
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/f2636ec186f82bd3.
Report an issue: GitHub.