安装 '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
和自定义 Wrapper 任务: https://docs.gradle.org/5.2.1/userguide/gradle_wrapper.html#customizing_wrapper
关于android - 无法将任务 'wrapper' 添加为具有该名称的任务已存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53709282/