Search code examples
androidandroid-libraryandroid-lint

Best usage of SuppressWarnings Unused in library


I'm developing an Android library and I wanted to clean all warnings. Most of them is due to unused methods. I don't want to remove this methods from the class as it could be used by other developer.

Should I:

  • add @SuppressWarnings("unused") on methods or class?
  • remove the methods anyway?
  • use this methods in the project app that is using the library (for development purpose). This will remove the warning but will add some junk code to the app?
  • or?

If I annotate the class to suppress this warnings it will solve the issue but it will also prevent me for removing real unused methods.


Solution

  • Unused warning should only appear if a private method is never used. If a private method is never used, it is indeed dead code, since nobody could call it from outside. You should delete these methods. I hope you are using a version control system, so you can still find methods in the repository history.