{"record":{"id":"66f0eb835cb19599","repo":"MuntashirAkon/AppManager","slug":"manifest-does-not-have-required-attribute-package","errorCode":null,"errorMessage":"\"manifest\" does not have required attribute \"package\".","messagePattern":"\"manifest\" does not have required attribute \"package\"\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/apk/parser/ManifestParser.java","lineNumber":71,"sourceCode":"    }\n\n    public ManifestParser(@NonNull ByteBuffer manifestBytes) {\n        mManifestBytes = manifestBytes;\n    }\n\n    public List<ManifestComponent> parseComponents() throws IOException {\n        try (BlockReader reader = new BlockReader(mManifestBytes.array())) {\n            ResXmlDocument xmlBlock = new ResXmlDocument();\n            xmlBlock.readBytes(reader);\n            xmlBlock.setPackageBlock(AndroidBinXmlDecoder.getFrameworkPackageBlock());\n            ResXmlElement resManifestElement = xmlBlock.getDocumentElement();\n            // manifest\n            if (!TAG_MANIFEST.equals(resManifestElement.getName())) {\n                throw new IOException(\"\\\"manifest\\\" tag not found.\");\n            }\n            String packageName = getAttributeValue(resManifestElement, ATTR_MANIFEST_PACKAGE);\n            if (packageName == null) {\n                throw new IOException(\"\\\"manifest\\\" does not have required attribute \\\"package\\\".\");\n            }\n            mPackageName = packageName;\n            // manifest -> application\n            ResXmlElement resApplicationElement = null;\n            Iterator<ResXmlElement> resXmlElementIt = resManifestElement.getElements(TAG_APPLICATION);\n            if (resXmlElementIt.hasNext()) {\n                resApplicationElement = resXmlElementIt.next();\n            }\n            if (resXmlElementIt.hasNext()) {\n                throw new IOException(\"\\\"manifest\\\" has duplicate \\\"application\\\" tags.\");\n            }\n            if (resApplicationElement == null) {\n                Log.i(TAG, \"package %s does not have \\\"application\\\" tag.\", mPackageName);\n                return Collections.emptyList();\n            }\n            // manifest -> application -> component\n            List<ManifestComponent> componentIfList = new ArrayList<>(resApplicationElement.getElementsCount());\n            String tagName;","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/apk/parser/ManifestParser.java#L53-L89","documentation":"ManifestParser.parseComponents throws IOException(\"\\\"manifest\\\" does not have required attribute \\\"package\\\".\") when the root <manifest> element exists but lacks the mandatory android-namespace-less \"package\" attribute that names the app. The package name is required to populate mPackageName, so without it parsing cannot continue.","triggerScenarios":"parseComponents reads the root manifest element successfully, but getAttributeValue(element, ATTR_MANIFEST_PACKAGE) returns null — i.e. the AXML root has no package attribute, typically because the manifest was built/repacked without it (e.g. with aapt2 'generate without package', heavy resource obfuscation, or hand-crafted AXML).","commonSituations":"APKs repackaged by tools that strip the package attribute, manifests synthesized programmatically and compiled without package, or merged-manifest builds gone wrong. Rarely seen with APKs produced by normal Gradle/aapt builds.","solutions":["Rebuild the APK with a standard build (Gradle/aapt2) so <manifest package=\"...\"> is emitted.","If repackaging, preserve the package attribute on the manifest root before recompiling AXML.","Verify with aapt dump badging that the APK reports a package name before parsing.","Fall back to reading packageName from PackageInfo/PackageParser if the attribute is missing."],"exampleFix":"// before\nString packageName = getAttributeValue(resManifestElement, ATTR_MANIFEST_PACKAGE);\nif (packageName == null) throw new IOException(\"\\\"manifest\\\" does not have required attribute \\\"package\\\".\");\n// after\nString packageName = getAttributeValue(resManifestElement, ATTR_MANIFEST_PACKAGE);\nif (packageName == null) {\n    packageName = fallbackPackageNameFromArchive(); // e.g. from APK path or PackageParser\n    if (packageName == null) {\n        throw new IOException(\"\\\"manifest\\\" does not have required attribute \\\"package\\\".\");\n    }\n}\nmPackageName = packageName;","handlingStrategy":"try-catch","validationCode":"// After decoding, confirm the manifest declares a package before full parse\n// (higher-level check: the APK must report a package via aapt/badging)\n// adb shell aapt dump badging app.apk | grep '^package:'","typeGuard":null,"tryCatchPattern":"try {\n    manifestParser.parse();\n} catch (IOException e) {\n    if (e.getMessage().contains(\"required attribute \\\"package\\\"\")) {\n        report(\"Manifest lacks package attribute; APK likely repackaged or malformed\");\n    } else throw e;\n}","preventionTips":["Use APKs built by standard Gradle/aapt2 toolchains; avoid hand-crafted AXML.","If repackaging, always preserve the package attribute on the manifest root.","Sanity-check with `aapt dump badging` (package: name=...) before parsing.","Have a fallback package-name source (filename convention or PackageParser) for damaged manifests."],"tags":["android","apk","axml","manifest","missing-attribute"],"backgroundTag":"missing-required-argument","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}