{"record":{"id":"d4177f6a8ae1d191","repo":"bazelbuild/bazel","slug":"the-manifest-tag-in-the-manifest-at-s-needs-to","errorCode":null,"errorMessage":"The <manifest> tag in the manifest at %s needs to specify the package name using the 'package' attribute.","messagePattern":"The <manifest> tag in the manifest at (.+?) needs to specify the package name using the 'package' attribute\\.","errorType":"validation","errorClass":"ManifestError","httpStatus":null,"severity":"error","filePath":"tools/android/instrumentation_test_check.py","lineNumber":76,"sourceCode":"                        \"the targetPackage attribute is found in the \"\n                        \"manifest at %s\" % path)\n\n  if len(package_names) > 1:\n    raise ManifestError(\n        \"The <instrumentation> tags in the manifest at %s do not \"\n        \"reference the same target package: %s\" % (path, list(package_names)))\n\n  return package_names.pop()\n\n\ndef _ExtractTargetPackageName(xml_content, path):\n  \"\"\"Extract the package name value from the root <manifest> tag.\"\"\"\n  tree = ET.ElementTree(ET.fromstring(xml_content))\n  root = tree.getroot()\n  if \"package\" in root.attrib:\n    return root.attrib[\"package\"]\n  else:\n    raise ManifestError(\"The <manifest> tag in the manifest at %s needs to \"\n                        \"specify the package name using the 'package' \"\n                        \"attribute.\" % path)\n\n\ndef _ValidateManifestPackageNames(instr_manifest_content, instr_manifest_path,\n                                  target_manifest_content,\n                                  target_manifest_path):\n  \"\"\"Diff the package names and throw a ManifestError if not identical.\"\"\"\n  target_package_to_instrument = _ExtractTargetPackageToInstrument(\n      instr_manifest_content, instr_manifest_path)\n  target_package_name = _ExtractTargetPackageName(target_manifest_content,\n                                                  target_manifest_path)\n\n  if target_package_to_instrument != target_package_name:\n    raise ManifestError(\n        \"The targetPackage specified in the instrumentation manifest at \"\n        \"{instr_manifest_path} ({target_package_to_instrument}) does not match \"\n        \"the package name of the target manifest at {target_manifest_path} \"","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/tools/android/instrumentation_test_check.py#L58-L94","documentation":"Thrown by instrumentation_test_check.py's _ExtractTargetPackageName when the target app's manifest root <manifest> element has no 'package' attribute. The checker needs the app's package name to compare it against the instrumentation manifest's targetPackage, so the attribute is mandatory.","triggerScenarios":"The manifest supplied as the target manifest has a <manifest> root without package=\"...\" — for example it only declares uses-permission elements or relies on Gradle-style namespace injection.","commonSituations":"Passing the wrong file as --target_manifest; manifests generated without package (newer AGP moves package to build.gradle namespace); a trimmed placeholder manifest used in tests.","solutions":["Add package=\"com.example.app\" to the root <manifest> element of the target manifest.","Verify you are pointing --target_manifest at the real app manifest, not a fragment or the test manifest.","If the manifest is generated, fix the generation template to emit the package attribute."],"exampleFix":"<!-- before -->\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n<!-- after -->\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.example.app\">","handlingStrategy":"validation","validationCode":"root = ET.fromstring(target_manifest_content)\nassert 'package' in root.attrib, 'target manifest missing package attribute'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate manifests from a template that always emits the package attribute.","Wire --target_manifest to the real app manifest in the rule definition, not to hand-picked fragments."],"tags":["android","manifest","instrumentation-test","xml"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}