使用NewApi属性仍然会导致lint警告

我创建了自己的扩展函数来检查sdk是否至少是棒棒糖

inline val buildIsLollipopAndUp: Boolean get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP 

但是,如果我使用这个,lint工具无法弄清楚我已经验证了我的api级别,并且还给了我新的api警告。 无论如何要让这些警告消失,并让皮棉工具识别我的支票?

一个简单的例子:

 if (buildIsLollipopAndUp) ripple() else fade() 

ripple只能用于棒棒糖和向上的圆形动画, fade是默认的动画。

我完整的例子 :

 @SuppressLint("NewApi") @KauUtils fun View.circularReveal(x: Int = 0, y: Int = 0, offset: Long = 0L, radius: Float = -1.0f, duration: Long = 500L, onStart: (() -> Unit)? = null, onFinish: (() -> Unit)? = null) { if (!isAttachedToWindow) { onStart?.invoke() visible() onFinish?.invoke() return } if (!buildIsLollipopAndUp) return fadeIn(offset, duration, onStart, onFinish) val r = if (radius >= 0) radius else Math.max(Math.hypot(x.toDouble(), y.toDouble()), Math.hypot((width - x.toDouble()), (height - y.toDouble()))).toFloat() val anim = ViewAnimationUtils.createCircularReveal(this, x, y, 0f, r).setDuration(duration) anim.startDelay = offset anim.addListener(object : AnimatorListenerAdapter() { override fun onAnimationStart(animation: Animator?) { visible() onStart?.invoke() } override fun onAnimationEnd(animation: Animator?) = onFinish?.invoke() ?: Unit override fun onAnimationCancel(animation: Animator?) = onFinish?.invoke() ?: Unit }) anim.start() } 

请注意,我需要棉绒抑制器,以避免皮棉警告

它看起来像lint不知道如何扩大内联Kotlin变量。 我没有检查它是否扩展为Java。 稍后会这样做。

还指出…

  if(!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)) return val anim = ViewAnimationUtils.createCircularReveal(this, x, y, 0f, r).setDuration(duration) 

…不会抑制皮棉。 但…

  if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) val anim = ViewAnimationUtils.createCircularReveal(this, x, y, 0f, r).setDuration(duration) 

…将。 再一次,我没有检查Java是否也是如此。

所以,我怀疑这是一个Kotlin / Java问题。 我认为这是一个不起眼的问题。