今天想用 AS 运行 Java 文件,但是发现运行之后报 main() 方法的错误
具体报错如下:
11:06:09: Executing task 'JsonToLocal.main()'...
Executing tasks: [JsonToLocal.main()] in project E:\NodeDemo\mvvm20220312
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\Users\Administrator\AppData\Local\Temp\JsonToLocal_main__.gradle' line: 20
* What went wrong:
A problem occurred configuring project ':app:baseobservable'.
> Could not create task ':app:baseobservable:JsonToLocal.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 214ms
11:06:09: Task execution finished 'JsonToLocal.main()'.
度娘上很多博主说在.idea 下的 gradle.xml 下 GradleProjectSettings 结点增加以下代码:
<option name="delegatedBuild" value="false"/>
添加了之后如果没有实时生效的话,就重新启动 AS 即可
如果有小伙伴知道原理的话请在评论区留言