Running Lint on Java / Kotlin modules

Starting with the Android Gradle Plugin 3.1.0 you can apply Android Lint to Java / Kotlin modules.


It’s as simple as adding the dependency of the Android Gradle Plugin and applying the Lint Plugin.

buildscript {
repositories {
dependencies {
classpath ""
apply plugin: "java-library"
apply plugin: ""


Configuring Lint can be done with the lintOptions DSL.

lintOptions {
abortOnError true
warningsAsErrors true
// Many many more.

You can look up all of the possible configurations here. The same configuration can also be used inside android modules with the android {} block.

Supported Lint issues

The number of supported built-in Lint checks is much lower though since not every Lint check that targets Android is also applicable to non-android projects.

For example, one check that is supported is GradleDependency. It checks if a newer version of your dependency is available. A report after running ./gradlew lint can look like this:


3.1.0 is super old. It’s best to use the 3.2.0 version which is currently 3.2.0-rc02. They have fixed a lot of things there. If you’re even more adventurous and you should be, use 3.3.0-alpha07. There you get all of the latest goodies.


It’s nice that we can use Lint for Java / Kotlin modules. It does already provide great benefit however there are still a few things to improve:

Mainly, I think this is because not that many people know that Lint can be used on Java and Kotlin modules. In case you find anything you can report it on their issue tracker.

If you want a sample project where the Lint Plugin is applied be sure to check mine out.

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store