8 <h2>In this document</h2>
10 <li><a href="#syntax">Syntax</a></li>
11 <li><a href="#options">Options</a></li>
12 <li><a href="#config_keywords">Configuring Java and XML Source Files</a></li>
17 <p>The Android {@code lint} tool is a static code analysis tool that checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. </p>
18 <p>For more information on running {@code lint}, see <a href="{@docRoot}tools/debugging/improving-w-lint.html">Improving Your Code with lint</a>.</p>
20 <h2 id="syntax">Syntax</h2>
22 <pre>lint [flags] <project directory></pre>
24 For example, you can issue the following command to scan the Java and XML files under the {@code myproject} directory and its subdirectories. The result is displayed on the console.
25 <pre>lint myproject</pre>
27 You can also use {@code lint} to check for a specific issue. For example, you can run the following command to scan the files under the {@code myproject} directory and its subdirectories to check for XML attributes missing the Android namespace prefix. The issue ID {@code MissingPrefix} tells lint to only scan for this issue.
28 <pre>lint --check MissingPrefix myproject</pre>
30 You can create an HTML report for the issues that {@code lint} detects. For example, you can run the following command to scan the {@code myproject} directory and its subdirectories for accessibility issues, then generate an HTML report in the {@code accessibility_report.html} file.
31 <pre>lint --check Accessibility --HTML accessibility_report.html myproject</pre>
34 <h2 id="options">Options</h2>
35 <p>Table 1 describes the command-line options for {@code lint}.</p>
36 <p class="table-caption" id="table1">
37 <strong>Table 1.</strong> Command-line options for lint</p>
47 <td rowspan="7">Checking</td>
48 <td><nobr><code>--disable <list></code></nobr></td>
49 <td>Disable checking for a specific list of issues.</td>
50 <td>The <code><list></code> must be a comma-separated list of {@code lint} issue IDs or categories.</td>
54 <td><nobr><code>--enable <list></code></nobr></td>
55 <td>Check for all the default issues supported by {@code lint} as well as the specifically enabled list of issues.</td>
56 <td>The <code><list></code> must be a comma-separated list of {@code lint} issue IDs or categories.</td>
60 <td><nobr><code>--check <list></code></nobr></td>
61 <td>Check for a specific list of issues.</td>
62 <td>The <code><list></code> must be a comma-separated list of {@code lint} issue IDs or categories.</td>
66 <td><nobr><code>-w</code> or <code>--nowarn</code></nobr></td>
67 <td>Only check for errors and ignore warnings</td>
72 <td><nobr><code>-Wall</code></nobr></td>
73 <td>Check for all warnings, including those that are disabled by default</td>
78 <td><nobr><code>-Werror</code></nobr></td>
79 <td>Report all warnings as errors</td>
84 <td><nobr><code>--config <filename></code></nobr></td>
85 <td>Use the specified configuration file to determine if issues are enabled or disabled for {@code lint} checking</td>
86 <td>If the project contains a {@code lint.xml} file, the {@code lint.xml} file will be used as the configuration file by default.</td>
90 <td rowspan="9">Reporting</td>
91 <td><nobr><code>--html <filename></code></nobr></td>
92 <td>Generate an HTML report.</td>
93 <td>The report is saved in the output file specified in the argument. The HTML output includes code snippets of the source code where {@code lint} detected an issue, a verbose description of the issue found, and links to the source file.</td>
97 <td><nobr><code>--url <filepath>=<url></code></nobr></td>
98 <td>In the HTML output, replace a local path prefix <code><filepath></code> with a url prefix <code><url></code>.</td>
99 <td>The {@code --url} option only applies when you are generating an HTML report with the {@code --html} option. You can specify multiple <filepath>=<url> mappings in the argument by separating each mapping with a comma.<p>To turn off linking to files, use {@code --url none}</p></td>
103 <td><nobr><code>--simplehtml <filename></code></nobr></td>
104 <td>Generate a simple HTML report</td>
105 <td>The report is saved in the output file specified in the argument.</td>
109 <td><nobr><code>--xml <filename></code></nobr></td>
110 <td>Generate an XML report</td>
111 <td>The report is saved in the output file specified in the argument.</td>
115 <td><nobr><code>--fullpath</code></nobr></td>
116 <td>Show the full file paths in the {@code lint} checking results.</td>
121 <td><nobr><code>--showall</code></nobr></td>
122 <td>Don't truncate long messages or lists of alternate locations.</td>
127 <td><nobr><code>--nolines</code></nobr></td>
128 <td>Don't include code snippets from the source files in the output.</td>
133 <td><nobr><code>--exitcode</code></nobr></td>
134 <td>Set the exit code to 1 if errors are found.</td>
139 <td><nobr><code>--quiet</code></nobr></td>
140 <td>Don't show the progress indicator.</td>
145 <td rowspan="4">Help</td>
146 <td><nobr><code>--help</code></nobr></td>
147 <td>List the command-line arguments supported by the {@code lint} tool.</td>
148 <td>Use {@code --help <topic>} to see help information for a specific topic, such as "suppress".</td>
152 <td><nobr><code>--list</code></nobr></td>
153 <td>List the ID and short description for issues that can be checked by {@code lint}</td>
158 <td><nobr><code>--show</code></nobr></td>
159 <td>List the ID and verbose description for issues that can be checked by {@code lint}</td>
160 <td>Use {@code --show <ids>} to see descriptions for a specific list of {@code lint} issue IDs.</td>
164 <td><nobr><code>--version</code></nobr></td>
165 <td>Show the {@code lint} version</td>
172 <h2 id="config_keywords">Configuring Java and XML Source Files</h2>
173 <p>To configure lint checking, you can apply the following annotation or attribute to the source files in your Android project. </p>
175 <LI>To disable lint checking for a specific Java class or method, use the <code>@SuppressLint</code> annotation. </LI>
176 <li>To disable lint checking for specific sections of your XML file, use the <code>tools:ignore</code> attribute. </li>
178 <p>You can also specify your lint checking preferences for a specific Android project in the lint.xml file. For more information on configuring lint, see <a href="{@docRoot}tools/debugging/improving-w-lint.html">Improving Your Code with lint</a>.</p>