A lot of us probably do know what actually Android Lint is, even if we don’t know the name. Because it is the thing that shows warning messages in the IDE. It may be warnings or errors that will actually fail the build. The following images shows an example of Lint suggestions.
Gradle version out of date
Not calling super method where expected
Android Studio provides a code scanning tool called lint that can help you to identify and correct problems with the structural quality of your code. For example, Lint can help us clean up these issues
The problems detected in our code by the Lint will be reported to us with some suggestions and a warning level. We can use the suggestion to correct our code. Lint can customized to see a particular type of error in our project. When using Android Studio, inspection process run whenever we build our project. However, we can manually run inspections or run lint from the command line.
The basic topics that is covered are:
By Android Studio:
In order to manually inspect a file in Android Studio, click on **Analyze > Inspect Code. **Below window will be opened:
Here we can select your inspection scope i.e. whole project or module or simply a file. After selecting the scope click on OK.
Under Inspection Results, in the left pane tree view, error categories, types, and issues is displayed.
The right pane displays the inspection report for the selected error category, type, or issue and provides the name and location of the error.
Run lint from the command line:
Invoke the lint
task for your project by entering one of the following commands from the root directory of your project:
On Windows:
gradlew lint
On Linux or Mac:
./gradlew lint
When the lint tool completes its checks, it provides paths to the XML and HTML versions of the lint report.
#android-app-development #android-lint #code-optimization