question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ktlintFormat and ktlintCheck are not working.

See original GitHub issue

I’m trying to apply the plugin to an Android project, but ktlintFormat and ktlinCheck are not working.

For example, let’s take this simple Kotlin file that contains an activity and it’s not well formatted

package com.gianfranco.stormy

import android.os.Bundle
import android.support.v7.app.AppCompatActivity

    class MainActivity : AppCompatActivity() {
            override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(     savedInstanceState)

                setContentView(R.layout.activity_main)
    }
}

When I run ./gradlew ktlintCheck or ./gradlew ktlintFormat, nothing happens. The output is BUILD SUCCESSFUL.

The build.gradle for the project can be found here

I’m using Gradle 4.8.1 and AGP 3.2.0-beta03.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
JLLeitschuhcommented, Jul 18, 2018

Try also applying the plugin in the allprojects block.

1reaction
VincentJoshuaETcommented, Sep 1, 2021

@GianfrancoMS I can’t find ktlint-gradle configuration in your develop branch build.gradle.

Note, that to use this plugin with android plugin, you should use classpath approach, not plugins {} config block.

Why is this? Is this still an issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Task 'ktlintCheck' not found in project - Stack Overflow
I have installed the pre-commit hook successfully. The 4 below attempts are working the same way even if use app:ktlintCheck. I can run...
Read more >
Configuring and running Ktlin on Android Studio
Hello Folks!! The goal of this post is help you to configure and run locally the static code analysis called Ktlint on Android...
Read more >
Code Formatting in Kotlin using ktlint - GeeksforGeeks
gradlew ktlintFormat. This will attempt to auto-fix any errors and will report back any issues that could not automatically be fixed.
Read more >
lampietti / ktlint-gradle Download - JitPack
This plugin has only been tested with gradle 3.5 and should work with versions ... also adds two meta tasks ktlintCheck and ktlintFormat...
Read more >
Ktlint
No configuration required ktlint aims to capture the official Kotlin coding conventions and Android Kotlin Style Guide. · Rule sets ktlint offers a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found