无法添加任务“包装器",因为该名称的任务已经存在 [英] Cannot add task 'wrapper' as a task with that name already exists

查看:251
本文介绍了无法添加任务“包装器",因为该名称的任务已经存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装'react-native init AwesomeProject'时,我在运行react-native run-android时收到此错误:

When installing 'react-native init AwesomeProject' I get this error when I run react-native run-android:

Could not determine java version from '11.0.1'.

一个快速的Google建议我需要在Gradle-wrapper中更新distributionUrl.完成此操作后,我面临一个新错误:

A quick google suggests I need to update the distributionUrl in the Gradle-wrapper. Having done this I am faced with a new error:

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

这表明问题出在文件中:

It suggests the issue is in the file:

/AwesomeProject/android/build.gradle' line: 36

看起来像这样

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

我一直在试图弄清楚这是怎么回事.某些东西开箱即用似乎很奇怪.有人面临类似的问题吗?

I've been back and forth trying to figure out what this does. It seems odd that something wouldn't work straight out of the box. Is anybody facing a similar issue?

推荐答案

您还可以更新

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

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

现在覆盖4.8中弃用的内置任务会产生错误.

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.

请参见任务与技术手册的最后一段.属性: https://docs.gradle.org/5.2.1/userguide/upgrading_version_4.html

自定义包装任务: https://docs.gradle.org/5.2.1/userguide/gradle_wrapper .html#customizing_wrapper

这篇关于无法添加任务“包装器",因为该名称的任务已经存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆