Android studio 执行main方法报错
2021-03-18 本文已影响0人
马路牙子666
Android studio 执行main方法报错
运行 Java main 方法报错
public class Hello {
public static void main(String[] args) {
System.out.println("Hello Java");
}
}
* Where:
Initialization script 'C:\xxx\Hello_main__.gradle' line: 21
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:Hello.main()'.
> SourceSet with name 'main' not found.
解决办法:
项目 .idea 文件夹中 gradle.xml 文件中 添加 <option name="delegatedBuild" value="false" /> ,添加完如下
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="1.8" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/hello" />
</set>
</option>
<option name="delegatedBuild" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>