Search code examples
androidlint

How to find the keyword to suppress a lint warning


I have the following lint warning:

Every Initializer needs to be accompanied by a corresponding entry in the AndroidManifest.xml

Usually, I just google or search SO for a warning and find the required keyword to suppress, e.g. tools:ignore="HardcodedText", but for newer warnings this doesn't always yield results.

Is there an 'official' way to find these suppress keywords? Android Studio often offers the correct suppression, where does it "look them up"?


Solution

  • There are 2 ways that I know of, but the steps may vary based on what kind of lint warning it is. In general you could try:

    1. Press Alt+Enter on the lint warning. (Sometimes the lint warning will also allow you to hover over it and click More Actions...).
    2. Then click the three dots (More Actions). Sometimes this will just be a >.
    3. Suppress the lint warning

    Suppress lint warning inline

    If that doesn't work you could try it like this:

    1. Open the Problems tab (Command+6)
    2. Find the lint warning you want to suppress, right click, Show Quick-Fixes.
    3. Then click the three dots (More Actions). Sometimes this will just be a >.
    4. Suppress the lint warning

    Suppress lint warning via problems tab