others-how to how to solve AAPT: error: unexpected element <queries> found in <manifest>?

1. Purpose

In this post, I would demonstrate how to solve AAPT: error: unexpected element <queries> found in <manifest>, just as follows:

.../app/src/main/AndroidManifest.xml:762:5-767:15: AAPT: error: unexpected element <queries> found in <manifest>.

2. The code and solution

2.1 The code

Here is the configuration in my AndroidManifest.xml:

<manifest>
    <application>
     ...
    </application>

    <queries>
        <intent>
            <action android:name="android.intent.action.SENDTO" />
            <data android:scheme="smsto"/>
        </intent>
    </queries>

</manifest>

2.2 The solution

This problem is caused by the gradle version, the old version is not compliant with the newly added <queries> element in androidmanifest.xml.

So you should upgrade your gradle version from 3.5.3 to 3.5.4, here is the list of patched gradle versions:

3.3.3
3.4.3
3.5.4
3.6.4
4.0.1

Now in my build.gradle:

buildscript {
    
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.4'
        ...
    }
}

You can refer to this article for more info.

If you are using an existing plugin in the 3.3.* through 4.0.* series, upgrade to the associated patch version (or higher) from that list, and you should no longer run into that error (e.g., classpath ‘com.android.tools.build:gradle:4.0.1’).

If you are using Android Studio 4.1 or higher, with a matching Android Gradle Plugin (e.g., in the 4.1.* series), you should be fine without any changes. Those plugin versions were already aware of .

3. Summary

In this post, I demonstrated how to solve AAPT: error: unexpected element <queries> found in <manifest>. The key point is to check your gradle version , upgrade your gradle to be compliant with the newly added android manifest tags. That’s it, thanks for your reading.

-->