Supported @SuppressWarnings Values in Android Studio
JavaAndroidIntellij IdeaAndroid StudioJava Problem Overview
What are all of the supported values for @SuppressWarnings
in Android Studio?
I couldn't find any documentation on it, and I know it isn't the same as Eclipse because "null" doesn't work. You can catch null warnings with "all", but as you can imagine I'd rather not.
Java Solutions
Solution 1 - Java
Press Alt+Enter (Windows, Linux) or Option+Enter (OS X), then either press → or click on the arrow pointing right at the end of "Replace with lambda...", finally select some of the Suppress... menu items available.
Solution 2 - Java
Look at this page for list of @SuppressWarnings
:
Solution 3 - Java
I couldn't get any of the above solutions work for me, or rather what they were saying seemed not to apply to my version of Android Studio (3.4.1) running on Windows 10. Here's what I did to solve this problem of not knowing what string value to supply to @SuppressWarnings
I ran the "Analyze/Inspect Code..." for the module in question. You'll get an "Inspection Results" window. Navigate that window until you find the lint warning line that you want suppressed. Double clicking on the error message will take you to line of code that the warning message applies to. Right clicking on the error message will give you a drop-down menu, and you'll get an option to suppress the warning on a class, method or parameter basis. Select the way you want the warning message suppressed. Navigate to the code and you'll see the @SuppressWarning line that was added. You'll see the actual string parameter passed to the @SuppressWarning line.
If you rerun "Analyze/Inspect Code.." again, that same warning will show up in the "Inspection Result" window, but this time you'll see that the line will also say that it's suppressed.
Solution 4 - Java
This is very simple, just click on the deprecated word and press ALT + ENTER on your keyboard, click on --> Inspection 'Deprecated API usage' options. In the drop-down menu, u can select the option that matches your choice, e.g Suppress for class, Suppress for method, Suppress for statement.. Hope it helps.
Solution 5 - Java
I wanted to suppress "function never used" warnings and none of the @SuppressWarnings worked, but @Suppress("unused") did work.