How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修复“意外元素lt;查询gt;在“清单中找到错误?)
问题描述
突然间,我在我的 Android 项目中遇到了这个构建错误:
All of a sudden, I am getting this build error in my Android project:
unexpected element <queries> found in <manifest>
我该如何解决?
推荐答案
Android Gradle 插件需要了解新的清单元素,尤其是对于清单合并过程.如果插件有混淆的趋势在清单合并中看到它无法识别的元素,扔掉构建问题中的错误.
The Android Gradle Plugin needs to know about new manifest elements, particularly for the manifest merger process. The plugin has a tendency to get confused if it sees elements in the manifest merger that it does not recognize, tossing out build errors like the one in the question.
在这种情况下,Android 11 引入了 <queries> 作为清单元素,而旧版本的 Android Gradle 插件不知道该元素.
In this case, Android 11 introduced <queries> as a manifest element, and older versions of the Android Gradle Plugin do not know about that element.
从清单合并中发生的事实意味着只需升级依赖项可能会导致这个错误.例如,如果您升级到最新com.awesome:awesome-library 的版本,它包含一个 <queries> 元素在其清单中,您可能会因构建中的上述错误而崩溃,即使您的代码没有任何其他更改.
The fact that this occurs from manifest merger means that simply upgrading a dependency
might bring about this error. For example, if you upgrade to the latest
version of com.awesome:awesome-library, and it contained a <queries> element
in its manifest, you might crash with the aforementioned error in your builds,
even without any other changes in your code.
Google 发布了一系列补丁版本的 Android Gradle 插件来解决这个问题:
Google released a series of patch versions of the Android Gradle Plugin to address this:
3.3.33.4.33.5.43.6.44.0.1
如果您使用的是 3.3.* 到 4.0.* 系列中的现有插件,请升级到该列表中的关联补丁版本(或更高版本),您不应该再遇到该错误(例如,classpath 'com.android.tools.build:gradle:4.0.1').
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').
如果您使用的是 Android Studio 4.1 或更高版本,请使用匹配的Android Gradle 插件(例如,在 4.1.* 系列中),你应该没问题任何变化.那些插件版本已经知道 <queries>.
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 <queries>.
请参阅 这篇 Android 开发者博客文章了解更多信息.
See this Android Developers Blog post for more.
这篇关于如何修复“意外元素<查询>在“清单"中找到错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何修复“意外元素<查询>在“清单
基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
