androidgradlepluginsandroid-gradle-pluginspotless

A problem was found with the configuration of task ':app:spotlessJava' (type 'SpotlessTask'). after gradle 7 update


I have updated to gradle 7.0.0 and there is such error : **

A problem was found with the configuration of task ':app:spotlessJava' (type 'SpotlessTask').

  • Type 'com.diffplug.gradle.spotless.SpotlessTask' property 'target' is missing an input or output annotation.

**

    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0'
        classpath 'com.google.gms:google-services:4.3.8'
        classpath "com.diffplug.spotless:spotless-plugin-gradle:3.24.2"
        // Crashlytics Gradle plugin.
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
project.tasks['preBuild'].dependsOn 'generateContactsXml'

apply plugin: "com.diffplug.gradle.spotless"
spotless {
    java {

        target '**/*.java'
        googleJavaFormat('1.6').aosp()
        removeUnusedImports()
    }
}
project.tasks['preBuild'].dependsOn 'spotlessApply'

Solution

  • Your Spotless plugin is too old to run on Gradle 7. You have to upgrade it. https://github.com/diffplug/spotless/issues/880