[Android] Configuring checkstyle for your Android project

1.- app/build.gradle

apply plugin: 'com.android.application'
apply plugin: 'checkstyle' // <-- add this line

android {
    // ...
}
task checkstyle(type: Checkstyle) {
    configFile = rootProject.file('config/checkstyle.xml')

    source 'src'
    include '**/*.java'
    exclude '**/gen/**'

    classpath = files()
}

dependencies {
    //  ...
}

2.- Create a file and name it checkstyle.xml inside project_root/config

You can find the contents of this file here

3.- You can now execute the checkstyle from your terminal

./gradlew checkstyle

Leave a comment