如何在 Android Studio 中为消息“调用需要 API 级别 21(当前最小值为 16)"启用 lint 错误? [英] How to enable lint error in Android Studio for message "Call requires API level 21 (current min is 16)"?
问题描述
我有一个名为 setImageTintList()
的方法,它要求 min API 为 21.但是,如果我在 gradle 中将 min API 设置为 16,该应用程序仍然可以在没有任何警告的情况下构建.
I have a method called setImageTintList()
that requires min API to be 21. But, if I set my min API to 16 in gradle, the app still builds without any warning.
虽然有一条红线说:
setImageTintList() - 调用需要 API 级别 21(当前最小值为 16)
setImageTintList() - Call requires API level 21 (current min is 16)
它不显示任何警告、错误或编译错误.
it does not show any warning, error or compile error.
如何在 android studio 中设置 lint 警告级别,以便在这种情况下它会出错并可能阻止构建?
How can I set the lint warning level in android studio such that it will error out and possibly prevent the build in cases like this?
推荐答案
Android 的 gradle 插件 lint 似乎无法将无效的 Android API 调用报告为错误.
It appears the Android's gradle plugin lint is not able to report invalid Android API calls as errors.
但你可以使用gradle-animalsniffer-plugin 以达到相同的目的.
But you can use the gradle-animalsniffer-plugin to achieve the same.
这篇关于如何在 Android Studio 中为消息“调用需要 API 级别 21(当前最小值为 16)"启用 lint 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!