java
build_error
ai_generated
true
在项目 ':app' 中未找到源集 'main'。请确保已应用 java 插件。
Source set 'main' not found in project ':app'. Please make sure the java plugin is applied.
ID: java/gradle-missing-source-set
80%修复率
85%置信度
0证据数
2025-02-14首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 7+ | active | — | — | — |
根因分析
未对项目应用 Java 插件,因此默认源集 'main' 和 'test' 不可用。
English
The Java plugin is not applied to the project, so the default source sets 'main' and 'test' are not available.
解决方案
-
95% 成功率 Apply the Java plugin to the project
plugins { id 'java' } -
95% 成功率 Apply the 'java-library' plugin if the project is a library
plugins { id 'java-library' }
无效尝试
常见但无效的做法:
-
Manually defining the source set without the Java plugin
80% 失败
The Java plugin provides necessary tasks and configurations; manual definition may lead to missing tasks.
-
Using the 'java-library' plugin instead of 'java'
50% 失败
The 'java-library' plugin extends 'java', so it also works, but the error may persist if not applied.