[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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s