加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Android:在清单中无法识别targetApi

发布时间:2020-12-15 02:14:58 所属栏目:Java 来源:网络整理
导读:我的清单中有以下行: intent-filter android:autoVerify="true" 但我得到一个lint警告: Attribute autoVerify is only used in API 23 and higher (current min is 16) 所以我改变它看起来像这样(根据android studio给我的建议): intent-filter android:a
我的清单中有以下行:

<intent-filter  android:autoVerify="true">

但我得到一个lint警告:

Attribute autoVerify is only used in API 23 and higher (current min is 16)

所以我改变它看起来像这样(根据android studio给我的建议):

<intent-filter  android:autoVerify="true" tools:targetApi="M">

然后我在构建apk时收到此错误:

Error:java.lang.RuntimeException: [path_to_manifest]/AndroidManifest.xml:58:13-67:29: Error: Invalid instruction 'targetApi',valid instructions are : REMOVE,REPLACE,STRICT

Caused by: java.lang.IllegalArgumentException: No enum constant com.android.manifmerger.AttributeOperationType.TARGETAPI

如何在摆脱棉绒警告的同时摆脱这个错误?

编辑:
我尝试了“清理项目”和“使缓存无效并重新启动” – 无法解决错误.

问题跟踪器上打开的问题:

https://code.google.com/p/android/issues/detail?id=211805

解决方法

我找到了答案 here,为此问题提供了解决方法.

通过使用该行:

<intent-filter  android:autoVerify="true"
            tools:ignore="UnusedAttribute">

解决了lint错误并且可以构建apk.我不打算将此标记为已接受的答案 – 我更喜欢有人可以解释如何使用targetApi(如果可以使用)?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读