Java – Android: targetapi is not recognized in the manifest
•
Android
My list has the following lines:
<intent-filter android:autoVerify="true">
But I got a lint warning:
Attribute autoVerify is only used in API 23 and higher (current min is 16)
So I changed it to look like this (according to the advice given to me by Android studio):
<intent-filter android:autoVerify="true" tools:targetApi="M">
Then I received this error when building 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
How to get rid of this mistake while getting rid of the lint warning?
Edit: I tried "clean item" and "invalidate cache and restart" – unable to resolve the error
Open issue on issue tracker:
https://code.google.com/p/android/issues/detail?id=211805
resolvent:
I found the answer here and provided a solution to this problem
By using this line:
<intent-filter android:autoVerify="true"
tools:ignore="UnusedAttribute">
I'm not going to mark this as an accepted answer – I prefer someone who can explain how to use targetapi (if available)?
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码