39

My source code is as follows:

There are warnings : Property '****' is never used.

I added "@Suppress("UNUSED_PARAMETER")", "@Suppress("UNUSED_PROPERTY_GETTER")", "@Suppress("UNUSED_PROPERTY_SETTER")",
however, none of them work.

How can I suppress this warning?

enter image description here

user3239558
  • 1,757
  • 4
  • 18
  • 31

1 Answers1

77

Use @Suppress("unused") in order to suppress unused warning.

For those cases you can use the IDE. press alt+enter: IDE unused suppress

Yoav Sternberg
  • 6,421
  • 3
  • 28
  • 30
  • 1
    Pressing Alt+Enter on an unused *property* (as in the question) rather than an unused *parameter* (as in this answer), I do not see any option to suppress the warning. – Laurence Gonsalves Jan 18 '18 at 21:26
  • 1
    For me, property works perfectly. The syntax I would never have come up with on my own, without me IDE though: `@file:Suppress("unused")` – Giszmo Apr 03 '18 at 23:18
  • I am using Android Studio, and it works for me perfectly – Francis Bacon Jul 31 '19 at 09:58
  • 1
    to me there's no option to press Alt + Enter, but I can add it manually and it loses this annoying warning – Chanh Dec 03 '19 at 03:24
  • 1
    odd I don't get that drop down, no safe delete option. Maybe cause I am on a method and not a class constructor? – JPM Dec 23 '21 at 18:13