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

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  1. 95% 成功率 Apply the Java plugin to the project
    plugins { id 'java' }
  2. 95% 成功率 Apply the 'java-library' plugin if the project is a library
    plugins { id 'java-library' }

无效尝试

常见但无效的做法:

  1. 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.

  2. 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.