Android Studio中运行java类中的main方法报错SourceSet with name ‘main‘ not found.
Posted guangdeshishe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Studio中运行java类中的main方法报错SourceSet with name ‘main‘ not found.相关的知识,希望对你有一定的参考价值。
错误提示:
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\\Users\\j2019.zhu\\AppData\\Local\\Temp\\MyTest_main__.gradle' line: 21
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:MyTest.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 1s
解决办法:
- 项目根目录下找到【.idea】目录下的【gradle.xml】文件
- 找到【delegatedBuild】选项并改为【false】
<GradleProjectSettings>
<option name="delegatedBuild" value="false"/>
如果没找到,则手动添加这一行
以上是关于Android Studio中运行java类中的main方法报错SourceSet with name ‘main‘ not found.的主要内容,如果未能解决你的问题,请参考以下文章
[Java] 使用Android Studio编写Java测试代码
我如何在android studio模拟器中运行vuzix android glass应用程序?
尝试在Android Studio中运行项目时,InstantRunNotificationTask中的NullPointerException