java build_error ai_generated true

Source set 'main' not found in project ':app'. Please make sure the java plugin is applied.

ID: java/gradle-missing-source-set

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2025-02-14First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7+ active

Root Cause

The Java plugin is not applied to the project, so the default source sets 'main' and 'test' are not available.

generic

中文

未对项目应用 Java 插件,因此默认源集 'main' 和 'test' 不可用。

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. Manually defining the source set without the Java plugin 80% fail

    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% fail

    The 'java-library' plugin extends 'java', so it also works, but the error may persist if not applied.