Android Lint: Ignore specific errors

The Android 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.


Running lint in command line

Running lint in Android Studio

To run lint in Android Studio go to Analyze > Inspect Code


Lint has a lot of option you can use in your build.gradle

See the complete options list in Gradle Plugin User Guide

To see the complete list of issues and categories id’s use:

Ignoring Erros

Lint is part of Gradle build process, by default if it fail your build will stop and you will get a message like it:

In 99% of the cases people will start ignore lint instead of fix the problems, adding this on build.gradle app

But IMHO it’s wrong. If lint is telling, you have a problem the best thing to do is fix it. Lint is a tools to make your app and the UX better.

Ignoring specific erros

Sometimes you really need to ignore some lint errors. For example, when you are using webView.getSettings().setJavaScriptEnabled(true); in your WebView

In this case, you should disable only the specific ids instead of disabling the whole lint.

You also can ignore it directly in your code:

Or in your XML

If you prefer you can move all your issues rules from a lint.xml file in the root directory of your project.