24

I have an Android project that includes generated code. This code has some lint violations in it that I don't want to show up in the lint reports because we won't fix this code problems manually.

Is it somehow possible to exclude folders in the lint check?

Janusz
  • 187,060
  • 113
  • 301
  • 369
  • See the [Lint docs](http://tools.android.com/tips/lint/suppressing-lint-warnings) for suppressing warnings. – corsair992 Jan 14 '14 at 17:00

3 Answers3

27

The correct way to do this is to add the following block to your app's lint.xml (this file is by default placed at the root of your app module):

<issue id="all">
    <ignore path="build" />
</issue>

This will instruct Lint to ignore all issues for the specified folder. If there is no lint.xml in your app module folder, create one with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="all">
        <ignore path="build" />
    </issue>
</lint> 
Volo
  • 28,673
  • 12
  • 97
  • 125
  • 7
    It worked well for lint <= 3.1, but for 3.2 it doesn't work. `lint` complains with `Error: Unknown issue id "all", found in ..../app/lint.xml [LintError]` – Alexander Skvortsov Sep 26 '18 at 21:08
  • Exactly what @AlexanderSkvortsov said, anyone knows how to make it work with `all`? – Julio_oa Oct 04 '18 at 15:49
  • 3
    @AlexanderSkvortsov this is a bug introduced in 3.2.0 by this [commit](https://android.googlesource.com/platform/tools/base/+/32969ce85a9115c66101e0e382431becc78c6e52%5E%21/lint/cli/src/main/java/com/android/tools/lint/LintCliClient.java). Please star the related Android issue: https://issuetracker.google.com/issues/116677290 – Volo Oct 05 '18 at 20:46
  • This should work again in AS 3.3 and 3.4: `Fixed by Change-Id: Ibe1154541bf4e1fce821030e10753bef28046790 for 3.4 and cherrypick to 3.3 in progress.` https://issuetracker.google.com/issues/116677290#comment4 – Volo Dec 12 '18 at 19:35
9

Add to your project 'lint.xml' file with content as such:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <ignore path="build" />
</lint>

for example to ignore build path of that project.

laalto
  • 150,114
  • 66
  • 286
  • 303
Michał Tajchert
  • 10,333
  • 4
  • 30
  • 47
6

I had to specify the issue id as well as the ignored path. The ignore path alone didn't work. Example with http://tools.android.com/tips/lint-checks lint check:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="MissingTranslation">
        <ignore path="build"/>
    </issue>
</lint>

You can find the issue id list here. Your lint.xml is placed in your project directory.

Example:

./app/lint.xml
L. G.
  • 9,642
  • 7
  • 56
  • 78