我的 list 中有以下行:
<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
如何在消除 lint 警告的同时消除此错误?
编辑: 我尝试了“清理项目”和“使缓存无效并重新启动”——都无法解决错误。
在问题跟踪器上打开的问题:
最佳答案
我找到了答案 here给出了此问题的解决方法。
通过使用行:
<intent-filter android:autoVerify="true"
tools:ignore="UnusedAttribute">
lint错误已解决,可以构建apk了。不过,我不会将此标记为已接受的答案 - 我更希望有人可以解释如何使用 targetApi(如果可以使用)?
关于java - Android: list 中无法识别 targetApi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37553946/