You can supply a comma separated list of issue id's, or the special value "all" to indicate all issues.
In Source: With Comments
In recent versions of lint, you can also use a special line comment on the line above the error to suppress a warning.
.gradle files, use a comment line this (where again the issue id can be a comma separated list of id's). You can prefix the id with "AndroidLint", which is allowed for consistency with the way IntelliJ disables inspections in comments.)
String path = "/sdcard/legacy.txt";
In XML files, the comment should look like this:
<!--suppress AndroidLintHardcodedText -->
In Build File: With Gradle Configuration
In Gradle files, you can specify a lintOptions configuration where you can disable id's, enable id's, as well as change the severity of issue id's (including to "ignore" to disable them).
From Command Line
The lint command has three commands for controlling which checks are performed:
(see the overview document
for more details on these flags). However, these must be specified each time you run lint. This is similar to the lintOptions for Gradle above.
To persistently configure which rules are run, you can create a file named
lint.xml in the root directory of your project (next to the manifest file). Lint will automatically look at this file and use it to ignore warnings. Gradle, Android Studio and Eclipse will also use this configuration file if present. Note that when you use Eclipse to suppress errors, it automatically creates this file for you, so you can use Eclipse to ignore warnings and then check in the resulting configuration file such that for example build server lint runs will ignore warnings you've manually verified.
Here's a sample lint.xml file (the comments are obviously not needed; I've added them here to explain what each line does)
<?xml version="1.0" encoding="UTF-8"?>
Disable the given check in this project
<issue id="IconMissingDensityFolder" severity="ignore" />
Ignore the ObsoleteLayoutParam issue in the
<ignore path="res/layout/activation.xml" />
<ignore path="res/layout-xlarge/activation.xml" />
Ignore the UselessLeaf issue in the given file
<ignore path="res/layout/main.xml" />
Change the severity of hardcoded strings
<issue id="HardcodedText" severity="error" />
In recent versions of lint (Gradle plugin 0.9+, SDK Tools 27+, Android Studio 0.5+) you can use a globbing pattern for the path:
<ignore path="res/**/activation.xml" />
You can also specify a full regular expression, by using a regexp attribute instead of path:
<ignore regexp="res/.*/activation.xml" />
The issue identifiers used to suppress issues as shown above (IconMissingDensityFolder, ObsoleteLayoutParam etc) are the issue ids, which are included in the error output from the lint command:
Warning: The resource R.drawable.robot appears to be unused [UnusedResources]
You can also look up the lint ids with the
command (for full details) or
(for a brief summary):
$ lint --list
"ContentDescription": Ensures that image widgets provide a contentDescription
"DuplicateIncludedIds": Checks for duplicate ids across layouts that are
combined with include tags
"DuplicateIds": Checks for duplicate ids within a single layout
"StateListReachable": Looks for unreachable states in a <selector>
"InefficientWeight": Looks for inefficient weight declarations in
"NestedWeights": Looks for nested layout weights, which are costly
This lint configuration file apply to the current project, as well as any library projects included into this project. If you want to also have a "global" configuration used for all projects, you can create an additional global file and then invoke lint with the
--config <filename> Use the given configuration file to determine whether
issues are enabled or disabled. If a project contains
a lint.xml file, then this config file will be used
as a fallback.
From Android Studio
You can configure lint severities from the global inspections menu. However, these will only be used inside Studio itself. If you want the Gradle command line build and other users to see your altered severities, use a lint.xml file or a Gradle lintOptions configuration instead.
To suppress an error, open the issue in the editor and run the quickfix/intentions action (Ctrl/Cmd F1) and select Suppress which will use annotations, attributes or comments to disable the issue.
If you're using the Eclipse Lint plugin, you can suppress errors directly from the Lint Window. There are three separate ignore levels:
- Always ignore. This completely suppresses the given warning. Use this for warnings you never want flagged.
- Ignore in project. This will ignore this warning in the current project (and any library projects referenced from this project).
- Ignore in file. This will ignore this warning anywhere in the current file, but not in any other files.
- (Ignore warnings within a class, method or even for a specific variable declaration, using annotations or attributes: See this document for more information.)
(Note that support for all 3 in the Lint view is coming in ADT 17; in ADT 16 you can access these from the quick fix menu in the XML editors, and you can access the first two from the Global Options dialog and from the Project Options dialog.)
Project and file specific warnings are written into
lint.xml files into the projects, so command line and build server lint runs will pick these up.