(#) Wrong manifest parent !!! ERROR: Wrong manifest parent This is an error, and is also enforced at build time when supported by the build system. For Android this means it will run during release builds. Id : `WrongManifestParent` Summary : Wrong manifest parent Severity : Fatal Category : Correctness Platform : Android Vendor : Android Open Source Project Feedback : https://issuetracker.google.com/issues/new?component=192708 Since : Initial Affects : Manifest files Editing : This check runs on the fly in the IDE editor See : https://developer.android.com/guide/topics/manifest/manifest-intro.html Implementation : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ManifestDetector.kt) Tests : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/ManifestDetectorTest.kt) Copyright Year : 2011 The `` element should be defined as a direct child of the `` tag, not the `` tag or an `` tag. Similarly, a `` tag must be declared at the root level, and so on. This check looks for incorrect declaration locations in the manifest, and complains if an element is found in the wrong place. (##) Example Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:7:Error: The element must be a direct child of the root element [WrongManifestParent] <uses-sdk android:minSdkVersion="Froyo" /> -------- AndroidManifest.xml:8:Error: The element must be a direct child of the root element [WrongManifestParent] <uses-permission /> --------------- AndroidManifest.xml:9:Error: The element must be a direct child of the root element [WrongManifestParent] <permission /> ---------- AndroidManifest.xml:10:Error: The element must be a direct child of the root element [WrongManifestParent] <permission-tree /> --------------- AndroidManifest.xml:11:Error: The element must be a direct child of the root element [WrongManifestParent] <permission-group /> ---------------- AndroidManifest.xml:13:Error: The element must be a direct child of the root element [WrongManifestParent] <uses-sdk /> -------- AndroidManifest.xml:14:Error: The element must be a direct child of the root element [WrongManifestParent] <uses-configuration /> ------------------ AndroidManifest.xml:15:Error: The element must be a direct child of the root element [WrongManifestParent] <uses-feature /> ------------ AndroidManifest.xml:16:Error: The element must be a direct child of the root element [WrongManifestParent] <supports-screens /> ---------------- AndroidManifest.xml:17:Error: The element must be a direct child of the root element [WrongManifestParent] <compatible-screens /> ------------------ AndroidManifest.xml:18:Error: The element must be a direct child of the root element [WrongManifestParent] <supports-gl-texture /> ------------------- AndroidManifest.xml:23:Error: The element must be a direct child of the element [WrongManifestParent] <uses-library /> ------------ AndroidManifest.xml:24:Error: The element must be a direct child of the element [WrongManifestParent] <activity android:name=".HelloWorld" -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloworld" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <!-- Wrong declaration locations --> <uses-sdk android:minSdkVersion="Froyo" /> <uses-permission /> <permission /> <permission-tree /> <permission-group /> <instrumentation /> <uses-sdk /> <uses-configuration /> <uses-feature /> <supports-screens /> <compatible-screens /> <supports-gl-texture /> </application> <!-- Wrong declaration locations --> <uses-library /> <activity android:name=".HelloWorld" android:label="@string/app_name" /> </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the [source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. The above example was automatically extracted from the first unit test found for this lint check, `ManifestDetector.testWrongLocation`. To report a problem with this extracted sample, visit https://issuetracker.google.com/issues/new?component=192708. (##) Suppressing You can suppress false positives using one of the following mechanisms: * Adding the suppression attribute `tools:ignore="WrongManifestParent"` on the problematic XML element (or one of its enclosing elements). You may also need to add the following namespace declaration on the root element in the XML file if it's not already there: `xmlns:tools="http://schemas.android.com/tools"`. ```xml <?xml version="1.0" encoding="UTF-8"?> <manifest xmlns:tools="http://schemas.android.com/tools"> ... <application tools:ignore="WrongManifestParent" .../> ... </manifest> ``` * Using a special `lint.xml` file in the source tree which turns off the check in that folder and any sub folder. A simple file might look like this: ```xml <?xml version="1.0" encoding="UTF-8"?> <lint> <issue id="WrongManifestParent" severity="ignore" /> </lint> ``` Instead of `ignore` you can also change the severity here, for example from `error` to `warning`. You can find additional documentation on how to filter issues by path, regular expression and so on [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html). * In Gradle projects, using the DSL syntax to configure lint. For example, you can use something like ```gradle lintOptions { disable 'WrongManifestParent' } ``` In Android projects this should be nested inside an `android { }` block. * For manual invocations of `lint`, using the `--ignore` flag: ``` $ lint --ignore WrongManifestParent ...` ``` * Last, but not least, using baselines, as discussed [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).