我是学习java的新手,并且相信我在某个地方遗漏了一步。我只是想在 android studio 中输出“Hello World”。
我正在通过 udemy 参加在线类(class),这让我完全停止了。我什至对电脑进行了彻底的删除,以确保我的设置不会出现任何问题。
package com.example.learnjava;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
期望在控制台中输出“Hello World”,但却收到以下错误:
11:20:01 PM: Executing task 'HelloWorld.main()'...
Executing tasks: [HelloWorld.main()] in project C:\Users\phuiz\AndroidStudioProjects\LearnJava
Configure project :app Unnecessarily replacing a task that does not exist has been deprecated. This is scheduled to be removed in Gradle 6.0. Try using create() or register() directly instead. You attempted to replace a task named 'HelloWorld.main()', but no task exists with that name already. at HelloWorld_main___8g5slkzupty1xjavpsz1qxha8$_run_closure1$_closure2.doCall(C:\Users\phuiz\AppData\Local\Temp\HelloWorld_main__.gradle:18) (Run with --stacktrace to get the full stack trace of this deprecation warning.)
FAILURE: Build failed with an exception.
Where: Initialization script 'C:\Users\phuiz\AppData\Local\Temp\HelloWorld_main__.gradle' line: 20
What went wrong: A problem occurred configuring project ':app'. Could not create task ':app:HelloWorld.main()'. SourceSet with name 'main' not found.
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 0s 11:20:01 PM: Task execution finished 'HelloWorld.main()'.
最佳答案
这是一个known bug .
要修复此问题,只需将您的 IntelliJ 版本升级到 2019.3 或更高版本即可。
关于java - 如何修复错误: Unnecessarily replacing a task that does not exist has been deprecated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57985217/