简体   繁体   English

如何在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)”?

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()的方法,该方法要求min API为21。但是,如果我在gradle中将min API设置为16,则该应用程序仍会生成而不会发出任何警告。

Although there is a red line saying: 尽管有一条红线说:

setImageTintList() - Call requires API level 21 (current min is 16) setImageTintList()-调用需要API级别21(当前最小值为16)

it does not show any warning, error or compile error. 它不显示任何警告,错误或编译错误。

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 studio中设置皮棉警告级别,这样它会出错并可能在这种情况下阻止构建?

It appears the Android's gradle plugin lint is not able to report invalid Android API calls as errors. 看来Android的gradle插件lint无法将无效的Android API调用报告为错误。

But you can use the gradle-animalsniffer-plugin to achieve the same. 但是您可以使用gradle-animalsniffer-plugin实现相同的目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 需要API级别21(当前最小值为16) - Requires API level 21 (current min is 16) Android皮棉:不显示消息“呼叫要求API级别17(当前最小值为14)” - Android lint: does not show message “Call requires API level 17 (current min is 14)” 调用要求API级别21,当前最小值为8 - Call requires API level 21, current min is 8 Android Lint错误:Class需要API级别3,current is min为1 - Android Lint error: Class requires API level 3, current is min is 1 L预览:呼叫需要API级别21(当前最小值为20) - L preview: Call requires API level 21 (current min is 20) 为什么Android Lint会说“调用要求API级别8(当前最小为8)”? - Why does Android Lint say “Call requires API level 8 (Current min is 8)”? Ripple需要API级别21(当前最小值为11),android? - Ripple requires API level 21 (current min is 11), android? 通话需要 API 级别 21(当前最低为 14):android.speech.tts.TextToSpeech#speak - Call requires API level 21 (current min is 14): android.speech.tts.TextToSpeech#speak 调用需要 API 级别 21(当前最小值为 17):android.hardware.camera2.CameraDevice.StateCallback - call requires API level 21 (current min is 17): android.hardware.camera2.CameraDevice.StateCallback 调用需要 api 级别 24(当前最小值为 21)新的 android.icu.text.DecimalFormat - call requires api level 24 (current min is 21) new android.icu.text.DecimalFormat
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM