Status Update
Comments
sa...@google.com <sa...@google.com>
tn...@google.com <tn...@google.com> #2
Interestingly I see this happening in the IDE when running ./studiow in the tree, which is Studio Chipmunk alpha 07 (see screenshot). I wonder if this is related to Kotlin (which I'm guessing has been updated in Chipmunk IDE, but probably only arrived with the recent 1.6 drop in dolphin.
tn...@google.com <tn...@google.com> #3
Actually no, I can boil it down to just the below. It looks like the issue is that the local @SdkSuppress annotation on the method makes lint think the minSdkVersion is 21, but when it dereferences the field it looks at its declaration being in a class (this class) as 23.
import androidx.annotation.RequiresApi
import androidx.test.filters.SdkSuppress
@SdkSuppress(minSdkVersion = 23)
@RequiresApi(23)
class Test {
private var scenario: Any? = null
@SdkSuppress(minSdkVersion = 21, maxSdkVersion = 29)
fun test() {
scenario?.toString()
}
}
tn...@google.com <tn...@google.com> #4
Lint gets confused here because when it reaches an outer annotation specifying an API level (@TargetSdk, @RequiresApi, @SdkSuppress) it assumes that's the highest requirement -- it doesn't keep looking outwards.
Here we have a @SdkSuppress(minSdkVersion=21) inside an outer class marked @SdkSuppress(minSdkVersion=23). That seems redundant; should lint flag this and suggest you remove this annotation? Well, for all the plain @SdkSuppress annotations in the file anyway which doesn't specify a maxSdkVersion.
Here, when we see a maxSdkVersion lower than the outer class minSdkVersion, we should suggest the method itself should never be called and can be deleted, right?
tn...@google.com <tn...@google.com> #5
I have a fix for this in
This does not seem like a new issue. My unit test that I added for that CL fails not just in 7.3 but in 7.2 and even 7.1 as well.
de...@google.com <de...@google.com> #7
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Dolphin Canary 4 (2021.3.1.4)
- Android Gradle Plugin 7.3.0-alpha04
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
DESCRIBE THE ISSUE IN DETAIL: Android lint NewApi regression, we get new false positives when upgrading AGP
7.3.0-alpha01
->7.3.0-alpha02
STEPS TO REPRODUCE:
Expected
No issues
Actual
Failure with: