Android

[Solved] – unexpected element queries found in manifest – Error

Today we are going to solve the gradle issue ‘unexpected element <queries> found in <manifest>- Error’ in android.

The Android Gradle Plugin plays a crucial role in the build process of Android applications. One of its tasks is the manifest merging process, where it combines various manifest files (such as the app’s main manifest, library manifests, and others) into a single manifest that defines the app’s configuration.

With the introduction of Android 11, a new manifest element called was added. This element allows apps to declare which third-party apps’ components (like activities, services, etc.) they need to access, enhancing user privacy and security.

However, older versions of the Android Gradle Plugin might not be aware of this new element. When attempting to merge manifests containing this unfamiliar element, the plugin can encounter confusion and subsequently throw build errors. These errors can cause the build process to fail, hindering app development.

Interestingly, this issue can arise unexpectedly. For instance, upgrading a dependency, such as a library (like com.awesome:awesome-library), could introduce the element into the merged manifest. This change alone, without any modifications in your code, might trigger the build error related to unrecognized manifest elements.

This scenario highlights the importance of keeping the Android Gradle Plugin up-to-date, as newer versions are equipped to handle new manifest elements and avoid such build errors. Additionally, it emphasizes the need for caution when updating dependencies, as they can inadvertently introduce elements that the older plugin versions might not support, leading to unexpected build issues.

Solution of “unexpected element <queries> found in <manifest>”

To tackle the issue of unexpected element <queries> found in <manifest>, Google swiftly released a series of patch versions for the Android Gradle Plugin. These versions, namely 3.3.3, 3.4.3, 3.5.4, 3.6.4, and 4.0.1, were specifically aimed at addressing the problem related to the introduction of the manifest element in Android 11.

Patch versions of the Android Gradle Plugin

1- 3.3.3
2- 3.4.3
3- 3.5.4
4- 3.6.4
5- 4.0.1

For developers using an existing plugin within the range of versions 3.3.* to 4.0.*, the solution was to upgrade to the associated patch version mentioned above (or a higher version if available). This upgrade, implemented by changing the plugin’s classpath in the project’s build file (for instance, classpath ‘com.android.tools.build:gradle:4.0.1’), resolved the issue by ensuring that the plugin was aware of and capable of handling the element during the manifest merging process.

Read this how to prepare gradle build for package visibility in android 11

However, for developers utilizing Android Studio 4.1 or higher and already using a matching Android Gradle Plugin version (e.g., in the 4.1.* series), there were no changes necessary. These plugin versions, released alongside Android Studio 4.1 and beyond, were already equipped and aware of the element. Therefore, developers using these versions didn’t encounter the build errors caused by the introduction of in their manifests.

This swift response from Google demonstrated their commitment to addressing compatibility issues promptly, providing developers with the necessary updates to ensure smooth app development experiences and compatibility with the evolving Android platform features.

Also read how to download image from url and save in local storage in android programmatically

Leave a Reply

Your email address will not be published. Required fields are marked *