/android-lint-checks-demo

A demo project that shows how to setup and write some basic custom lint checks.

Primary LanguageKotlinApache License 2.0Apache-2.0

android-lint-checks-demo

This is a simple demo repo that shows how to configure and write custom lint checks in an Android project.

Custom lint checks

Custom lint checks are a great way to prohibit usages of certain classes and resources in a codebase. To demonstrate their power, this project contains the following custom lint checks:

You can see the lint checks show up as errors if you open this project in Android Studio and look at the MainActivity.kt and activity_main.xml files.

You can view the unit tests for each custom lint check here.

Project setup

This project contains the following two modules:

Lint check jar library (checks/)

This module is the lint check jar library that other Android library modules can consume. It contains the custom lint check implementations listed above, each of which are listed in the IssueRegistry class.

Android app module (app/)

This module contains a generic sample Android app. In order to get the custom lint checks running on the code in this module, it depends on the checks module in the app/build.gradle file:

dependencies {
    lintChecks project(':checks')
}

Additional resources