writing android lint code

Android Lint

Reading Time: 2 minutes

“Android Lint”

There are many tools for writing android code but i like to prefer Android Studio.

Question is that why? why should we use android studio for development?

The best part of android studio is the support that it provided to developers like auto-suggestion, ease to use and improve our code quality by using feature “Lint tools”.

Now the again, question is that what is lint? how can we use this tool? so in this blog we will discuss following topics:

1. Introduction

2. When to use?

3. Configuration

Introduction Lint:

Lint is a code scanning tool provided by the Android Studio to identify, suggest and correct the wrong or the risky code present in the project.

When to use?

If you want to check every file of your code and make less buggy without any extra manually effort, you can use Lint.

By using lint, can inspect each and every file of your code to find some error and Lint will identify the errors and suggest some answers. That errors or warnings can be of:

  1. Unhandle Exceptions
  2. Unused variables
  3. Unused imports in file etc.


In order to use Lint or run inspections in your project, you can add Lint inspection in the lint.xml file or you can manually select the list of issues to be configured by the lint in your project by using Android Studio.

In this bog we will understand how can we configure using lint.xml file:

Create lint.xml file and put it into the root directory of your Android project.

<?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 specified files –>

<issue id=”ObsoleteLayoutParam”>

<ignore path=”res/layout/activation.xml” />

<ignore path=”res/layout-xlarge/activation.xml” />


<!– Change the severity of hardcoded strings to “error” –>

<issue id=”HardcodedText” severity=”error” />


then put this code into the android tag of build.gradle file:

lintOptions {

lintConfig rootProject.file(‘lint.xml’) // lint.xml file path


Now when run your code will get an error if you put any hardcode text into layout file.

if you want to run default lint errors which is provided by Android Studio so you can follow the steps below:

Go to Files > Settings > Editor > Inspections and then check the issue checks that you want to be performed by the lint

Thanks for reading this blog. In the next blog we will learn how can we create custom file for lint check.

Tags: No tags

Add a Comment

You must be logged in to post a comment