how to fix the issue of Missing ‘package‘ key attribute on element package

After got that failed log ,I try to find the grade version and find the below explanantion,in  url https://developer.android.google.cn/studio/releases/gradle-plugin

本次要更新支持与 Android 11 中软件包可见性的新默认设置和功能兼容。

在以前的 Android 版本中,可以查看设备上安装的所有应用的列表。从 Android 11(API 级别 30)开始,默认情况下,应用只能访问经过过滤的已安装软件包列表。如需查看系统上更广泛的应用列表,您现在需要在应用或库的 Android 清单中添加 <queries> 元素

Android Gradle 插件 4.1 及更高版本已与新的 <queries> 声明兼容;不过,较低的版本不兼容。如果您添加 <queries> 元素或者开始依赖于支持以 Android 11 为目标平台的库或 SDK,在构建应用时可能会遇到清单合并错误。

为了解决此问题,我们将针对 AGP 3.

如果您使用的是
AGP 版本...
...请升级到
4.0.*4.0.1
3.6.*3.6.4
3.5.*3.5.4
3.4.*3.4.3
3.3.*3.3.3

3 及更高版本发布一组补丁程序。如果您使用的是旧版 AGP,升级到以下某个版本

so try to fix the issue, you can modify the grade version,

for the right side grade version, it would fix the failed grade issue。

 

Ex: 

 I just use the Android studio 3.5.2, I just change 

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.4'  //old version is 3.5.2
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

in the build.gradle file

after modify the file and sync it again, then Android studio work normanly!

 

 


版权声明:本文为fu_shuwu原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。