Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Error: Unnecessarily replacing a task that does not exist has been deprecated

I am new to learning java, and believe I am missing a step somewhere. I am simply trying to output "Hello World" in android studio.

I am taking an online class through udemy, and this has halted me completely. I even did a complete PC wipe to ensure none of my settings were screwing anything up.

package com.example.learnjava;

public class HelloWorld {
    public static void main(String[] args) {
    System.out.println("Hello World");
    }
}

Expecting the output "Hello World" in the console, instead get the following error:

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()'.

like image 459
Paul Avatar asked Sep 18 '19 04:09

Paul


1 Answers

This is a known bug.

To fix it, just upgrade your IntelliJ version to 2019.3 or newer.

like image 151
dialex Avatar answered Oct 28 '22 21:10

dialex