@SuppressWarnings("unused") gives warning: Redundant suppression after Android Studio update
Asked Answered
M

1

12

I have a private methods in some low level classes that are not currently in use, but I don't want the "Method x is never used" warning potentially obscuring other more important warnings. I added a standard warning suppression for that method:

    @SuppressWarnings("unused")

Up until recently that was working fine, no warning for that method. After upgrading to AS 4.1.1, however, these have started to get a "Redundant suppression" warning. If I remove the suppression the original unused warning comes back.

I'm using Android Studio 4.1.1 (Nov. 4)

Melodics answered 16/12, 2020 at 17:56 Comment(2)
This problem remains with AS Android Studio 4.1.2 Build #AI-201.8743.12.41.7042882, built on December 19, 2020Lighting
This problem seems fixed with Android Studio 4.2 Build #AI-202.7660.26.42.7322048, built on April 29, 2021Festatus
M
12

Amusingly, I'm able to work around this by suppressing the suppression warning like so:

    @SuppressWarnings({"unused", "RedundantSuppression"})
Melodics answered 16/12, 2020 at 17:56 Comment(6)
I'm downvoting that to punish Android Studio, not you. This bug creates an infinite loop of suppression, suppressing the suppression, etc...Fusee
@Philip, that's not how the voting works. I think you're supposed to downvote only if there's a problem with the answer, not whether or not you like what the answer is about, no?Melodics
This really is amusing, thanks for the solution, and I'm pretty sure this should be reported as a bug against either AS or the SDK.Henriettahenriette
There is hope: youtrack.jetbrains.com/issue/IDEA-249790, indicating it's fixed in IntelliJ IDEA 20.2.3 while current Android Studio (4.1.3) is based on v. 20.1. Nice workaround. :)Greatest
This problem seems fixed with Android Studio 4.2 Build #AI-202.7660.26.42.7322048, built on April 29, 2021Festatus
Nice workaround. Bug still present in 2023 (Android Studio Electric Eel | 2022.1.1).Farcy

© 2022 - 2024 — McMap. All rights reserved.