Android Studio Gradle 适配 Android 11 升级出错了

为了适配Android 11,主要是Android 11 管理软件包可见性,具体参考 Android 开发文档 管理软件包可见性https://developer.android.google.cn/training/basics/intents/package-visibility?hl=en

我只是修改了 gradle/wrapper/gradle-wrapper.properties 中的 gradle 版本,为7.0.2,如下distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

编译出错如下,不多说上代码

1: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':app:checkHuaweiDebugManifest' (type 'CheckManifest').
  - Type 'com.android.build.gradle.internal.tasks.CheckManifest' property 'manifest' has @Input annotation used on property of type 'File'.
    
    Reason: A property of type 'File' annotated with @Input cannot determine how to interpret the file.
    
    Possible solutions:
      1. Annotate with @InputFile for regular files.
      2. Annotate with @InputDirectory for directories.
      3. If you want to track the path, return File.absolutePath as a String and keep @Input.
    
    Please refer to https://docs.gradle.org/7.0.2/userguide/validation_problems.html#incorrect_use_of_input_annotation for more details about this problem.
 

百度上没有找到相关的报错的资料,后台google 翻墙到 stack overflow 上找到相关的问题,gradle 升级了,要升级相应的 gradle 插件工具,也就是app 的 build.gradle 文件如下:

dependencies {
    classpath 'com.android.tools.build:gradle:4.2.2'
}
之前的是 lasspath 'com.android.tools.build:gradle:3.5.3'

具体参考 stack overflow: android - A problem was found with the configuration of task ':app:checkDebugManifest' (type 'CheckManifest') in flutter - Stack Overflow

因为适配 Android 11要升级到gradel 版本到 7.0.0以上,gradle 版本升级了 gradle 插件工具也要升级才正常,要不然编译通不过,详细可以参考Android开发文档:

Android Gradle 插件版本说明  |  Android 开发者  |  Android DevelopersAndroid Studio 构建系统以 Gradle 为基础,并且 Android Gradle 插件添加了几项专用于构建 Android 应用的功能。https://developer.android.google.cn/studio/releases/gradle-plugin#updating-plugin

以上是自己项目上填的坑,简单记录,方便以后查找,如有遇到同样问题的同学也可参考

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值