其他分享
首页 > 其他分享> > android – 无法将任务’wrapper’添加为具有该名称的任务已存在

android – 无法将任务’wrapper’添加为具有该名称的任务已存在

作者:互联网

当安装’react-native init AwesomeProject’时,我在运行’react-native run-android‘时遇到上述错误

Could not determine java version from '11.0.1'.

一个快速的谷歌建议我需要更新Gradle-wrapper中的distributionUrl.这样做后,我面临一个新的错误

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

它表明问题出在文件中:

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

看起来像这样

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

我一直在试图弄清楚这是做什么的.奇怪的是,某些东西不能直接开箱即用.是否有人面临类似的问题?

解决方法:

你也可以更新

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

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

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

标签:expo,android,reactjs,react-native,wrapper
来源: https://codeday.me/bug/20191004/1854571.html