【发布时间】:2020-04-14 10:01:44
【问题描述】:
我 2 天前开始学习 Java。当我尝试运行此代码时:
public class Main {
public static void main(String[] args) {
System.out.println(5*2);
}
}
终端说:
12:47:17 PM: Executing task 'Main.main()'...
Executing tasks: [Main.main()] in project C:\Users\Safakhan\AndroidStudioProjects\JavaBasics2
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\Users\Safakhan\AppData\Local\Temp\Main_main__.gradle' line: 20
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:Main.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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.6.4/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 298ms
12:47:17 PM: Task execution finished 'Main.main()'.
虽然,我试图删除
build.gradle(:app)
这是我的 gradle 文件的样子:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
}
但它没有奏效。你能请我解决这个问题吗?
【问题讨论】:
标签: java eclipse gradle intellij-idea