New: In ADT 17, you can also ignore warnings using annotations (in Java files) and using special attributes (in XML files). See this blog entry for more details. From the Command LineThe lint command has three commands for controlling which checks are performed: --enable, --disable and --check (see the overview document for more details on these flags). However, these must be specified each time you run lint.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. 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"?><lint> <!-- Disable the given check in this project --> <issue id="IconMissingDensityFolder" severity="ignore" /> <!-- Ignore the ObsoleteLayoutParam issue in the given files --> <issue id="ObsoleteLayoutParam"> <ignore path="res/layout/activation.xml" /> <ignore path="res/layout-xlarge/activation.xml" /> </issue> <!-- Ignore the UselessLeaf issue in the given file --> <issue id="UselessLeaf"> <ignore path="res/layout/main.xml" /> </issue> <!-- Change the severity of hardcoded strings to "error" --> <issue id="HardcodedText" severity="error" /></lint>The issue identifiers here (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]lint --show command (for full details) or lint --list (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 LinearLayouts"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 flag:--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.If you're using the Eclipse Lint plugin, you can suppress errors directly from the Lint Window. There are three separate ignore levels:
(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. |
