Gradle Wrapper Error - Cannot create task of type 'Wrapper'


(Shubham Goyal) #1

Hi. I am trying to shift to Gradle from maven. I want to use gradle wrapper in my gradle build. So I added wrapper task to my project’s build.gradle as -

task wrapper(type: Wrapper) {
    gradleVersion = '1.6'
}

But when I am trying to run my build I am getting this error -

A problem occurred evaluating root project 'MyProject'.
> Cannot create task of type 'Wrapper' as it does not implement the Task interface.

Any idea what I am doing wrong ?


(Peter Niederwieser) #2

That’s odd. Which Gradle version? Does it help to replace ‘Wrapper’ with ‘org.gradle.api.tasks.wrapper.Wrapper’?


(Shubham Goyal) #3

Thanks Peter. Replacing Wrapper with org.gradle.api.tasks.wrapper.Wrapper resolved the issue. I am using Gradle 1.6.


(Peter Niederwieser) #4

Is the build using any third-party plugins? What does ‘println Wrapper.name’ print?


(Shubham Goyal) #5

I am using three plugins -

apply plugin: 'android-library'
apply plugin: 'robolectric'
apply plugin: 'maven'

And println Wrapper.name is giving ‘java.sql.Wrapper’ .


(Peter Niederwieser) #6

Can you double-check that you don’t have ‘import java.sql.Wrapper’ in your build script?


(Shubham Goyal) #7

Oh yeah, somehow import java.sql.Wrapper got added in my build.gradle . I am building my project in Android Studio, so it is automatically importing java.sql.wraper in my build script.