buildSrc dir + CustomTask: Method 'doLast` is not implemented

Viewed 417

When a buildSrc directory exists, Android Studio will erroneously show Method 'doLast' is not implemented errors on custom tasks:

To verify the issue I create a new empty Android project in Android Studio (I use V 3.0.1) add a simple custom task to the root build.gradle file

class Greeting extends DefaultTask {
    String message
    String recipient

    @TaskAction
    void sayGreeting() {
        println "gradle version ${project.getGradle().getGradleVersion()}"
        println "${message}, ${recipient}!"
    }
}

task hello (type : Greeting) {
    group 'Welcome'
    description 'Produces a world greeting'
    message 'Hello'
    recipient 'World'
}

This is a very simple example from the gradle-guide Writing Gradle Tasks.
The default project uses my gradle V4.1 installation.

When I now refresh the Gradle projects, I can execute the hello task and the IDE shows no errors in the build.gradle file.

But when you now add a buildSrc dir to the project (can be empty) and refresh the Gradle projects again, Android Studio 3.0.1 shows this error: Method 'doLast' is not implemented
AS 3.0.1 Error Message

Any ideas what's going on and how to fix this (without implementing the missing methods)?

UPDATE:

0 Answers
Related