Jon*_*Jon 5 java android lint android-manifest android-studio
我的清单中有以下行:
<intent-filter android:autoVerify="true">
Run Code Online (Sandbox Code Playgroud)
但我收到了一个 lint 警告:
Attribute autoVerify is only used in API 23 and higher (current min is 16)
Run Code Online (Sandbox Code Playgroud)
所以我把它改成这样(根据android studio给我的建议):
<intent-filter android:autoVerify="true" tools:targetApi="M">
Run Code Online (Sandbox Code Playgroud)
然后我在构建 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
Run Code Online (Sandbox Code Playgroud)
如何在消除 lint 警告的同时消除此错误?
编辑:我尝试了“清理项目”和“使缓存无效并重新启动” - 两者都无法解决错误。
在问题跟踪器上打开的问题:
我在这里找到了答案,给出了解决此问题的方法。
通过使用该行:
<intent-filter android:autoVerify="true"
tools:ignore="UnusedAttribute">
Run Code Online (Sandbox Code Playgroud)
lint 错误已解决,可以构建 apk。不过,我不会将其标记为已接受的答案 - 我更希望有人可以解释如何使用 targetApi (如果可以使用)?
| 归档时间: |
|
| 查看次数: |
4453 次 |
| 最近记录: |