Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot add task 'wrapper' as a task with that name already exists

You can also update

task wrapper(type: Wrapper) {
    gradleVersion = '4.4'    
    distributionUrl = distributionUrl.replace("bin", "all")
}

to

wrapper {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

As

Overriding built-in tasks deprecated in 4.8 now produces an error.

Attempting to replace a built-in task will produce an error similar to the following:

Cannot add task 'wrapper' as a task with that name already exists.

see the last paragraph of Tasks & properties: https://docs.gradle.org/5.2.1/userguide/upgrading_version_4.html

and Customizing the Wrapper task: https://docs.gradle.org/5.2.1/userguide/gradle_wrapper.html#customizing_wrapper


which version of gradle do you use in your environment?

If you use gradle version 5.x you have to modify 「task wrapper」 as below.

task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

wrapper {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

if "gradle-wrapper.properties" file already have these codes

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

then you can remove

task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

from build.gradle


As mentioned in the comments follow - https://stackoverflow.com/a/46867575/4982729:

  1. Open and edit the file app-folder/android/gradle/wrapper/gradle-wrapper.properties; update the line

    distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
    
  2. In file AwesomeProject/android/build.gradle try commenting out

    task wrapper(type: Wrapper) {
        gradleVersion = '4.4'
        distributionUrl = distributionUrl.replace("bin", "all")
    }