不支持不必要地替换不存在的任务

2022-09-04 05:20:01

我得到以下错误:

FAILURE: Build failed with an exception.

* Where:
Initialization script 'C:\Users\User\AppData\Local\Temp\Console_main__.gradle' line: 18

* What went wrong:
A problem occurred configuring root project 'demo'.
> Could not create task ':Console.main()'.
   > Unnecessarily replacing a task that does not exist is not supported.  Use create() or register() directly instead.  You attempted to replace a task named 'Console.main()', but there is no existing task with that name.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 236ms
10:32:59 PM: Task execution finished 'Console.main()'.

答案 1

清除缓存并再次启动应用。当您最近升级了 gradle 时,可能会发生这种情况。如果您使用的是 intellij 想法,请选择文件 ->使缓存无效并重新启动。

如果您使用的是 gradle,请删除您的 .gradle 文件夹并再次运行 gradle。


答案 2

如果您使用的是Intellij想法,这可能会有所帮助:设置->构建,执行,部署-> Gradle->构建和运行使用:IntelliJ IDEA


推荐