6

I've noticed after the update to Android Studio 3 (but it could be happened also before and I didn't noticed) that some deprecated methods are not marked any more with a line-through. For example:

Code screenshot

I'm on Ubuntu, Android Studio 3.0.1 just updated. I checked inspections in the settings, and it's all enabled. I also checked that the code style/formatting is correctly set-up for deprecations (but it had to be, given the last line of the example is correctly marked). It's not something project-related, since I tried on a freshly created project.

What can cause this?

lorenzo-s
  • 16,603
  • 15
  • 54
  • 86

1 Answers1

13

I finally discovered that this is (strangely) the intended behaviour: https://issuetracker.google.com/65793314

What's your minSdkVersion? It's a feature that we now only show deprecated method calls as deprecated if they're deprecated for all the versions you're trying to target

So, getColor() and isAnimationCacheEnabled() are not marked in my example because I'm targeting API 15+, and instead they're deprecated as of API 23. I confirmed this raising my app's minSdkVersion to 23, and they are all marked now.

Anyway I find this behaviour confusing and unnecessary, like I said in the bug report. If someone read this and agrees, please leave a comment there.

lorenzo-s
  • 16,603
  • 15
  • 54
  • 86
  • 1
    This is still an issue in Android studio 4.1. Pretty annoying, if you ask me. Gradle build (Lint) reports something as deprecated (even though I use SDK_INT check there...), but AS doesn't tell me it's deprecated.... futhermore, when I use @SuppressWarning("deprecated") (to get rid of deprecation warning during build, which it does), AS tells me this suppresion is redundant... This is really inconsistent behavior. Not to mention Lint (during Gradle build) doesn't tell me on which API level something got deprecated... so I have to Google it myself for correct SDK_INT check... Ugh... – awa993 Oct 23 '20 at 13:16
  • So disappointed, IDE still don’t recognize deprecated or removed method that actual android api version changes. I must refactoring code, decrease api version and check for api changes – dphans Jul 09 '22 at 16:43
  • @awa993, just set @SuppressWarnings({"deprecation", "RedundantSuppression"}) to avoid message "Suppresion is redundant" – Amc Jun 27 '23 at 09:13