Make Apps Simple
Published in

Make Apps Simple

Android Spotless Easy Setup

Setup spotless in Android in 3 easy steps.

Step 1

Add ktlint and spotless plugin in the app build.gradle file.

plugins {
id ""
id "kotlin-android"
id "org.jlleitschuh.gradle.ktlint" version "<latest_version>"
id "com.diffplug.spotless" version "<latest_version>"
// Other plugins

You can find latest version of klint and spotless here,

Step 2

Create a new Gradle file at the project root level. It can have any name.


spotless {
// optional: limit format enforcement to just the files changed by this feature branch
ratchetFrom 'origin/main'

format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '*.md', '.gitignore'

// define the steps to apply to those files
indentWithSpaces() // or spaces. Takes an integer argument if you don't like 4
java {
// don't need to set target, it is inferred from java

// apply a specific flavor of google-java-format
// make sure every file has the following copyright header.
// optionally, Spotless can set copyright years by digging
// through git history (see "license" section below)
licenseHeader '/* (C)$YEAR */'

Step 3

Use this new file in the app build.gradle like this,

apply from: "$project.rootDir/spotless.gradle"

To run spotless

To check for issues

./gradlew spotlessCheck

To automatically fix issues

./gradlew spotlessApply




Working on ways to improve apps from planning, requirement gathering to end-user experience.

Recommended from Medium

Flutter From Zero to Hero. Part 4: Exploring InheritedWidget

godstale/EventPress (topic based event bus)

Make your own Flutter corner banners with Super Banners

Android Studio — 遇到app:kaptDebugKotlin

How to Build a Translator in Android Studio with ML Kit

Polyline and Marker using Google Map Sdk V3.0.0 BETA for Android Client

Lessons from my first multiplatform Kotlin project

How to get started with Realm Sync in your Android Application

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


Android Engineer @ GRAB | Linked In -

More from Medium

Live Video Streaming with Jetpack Compose and the Agora Android Video SDK

Exploring Photo Picker in Android 13

Monitoring Network Bandwidth Usage in the Doubtnut app.

Tabbed SlidingPaneLayout (Primary/Detail) using the Navigation Component Library ➡️🗔✨