gradle/gradle · warning
Could not read annotation processor declarations from {}. Gr
Error message
Could not read annotation processor declarations from {}. Gradle will assume that this directory contains no annotation processors. What it means
While scanning a classes directory for annotation processors, Gradle first reads META-INF/services/javax.annotation.processing.Processor (PROCESSOR_DECLARATION). If that read fails (getProcessorClassNames throws - I/O error, unreadable/corrupt declaration), Gradle assumes the directory contains NO annotation processors and returns an empty list. javac still discovers processors itself at execution time, but Gradle's incremental-processing bookkeeping for this directory is lost.
Source
Thrown at platforms/jvm/language-java/src/main/java/org/gradle/api/internal/tasks/compile/processing/AnnotationProcessorDetector.java:109
return detectProcessorsInClassesDir(file);
} else if (FileUtils.hasExtensionIgnoresCase(file.getName(), ".jar")) {
return detectProcessorsInJar(file);
}
return Collections.emptyList();
}
private List<AnnotationProcessorDeclaration> detectProcessorsInClassesDir(File classesDir) {
try {
List<String> processorClassNames = getProcessorClassNames(classesDir);
try {
Map<String, IncrementalAnnotationProcessorType> processorTypes = getProcessorTypes(classesDir);
return toProcessorDeclarations(processorClassNames, processorTypes);
} catch (Exception e) {
logger.warn("Could not read annotation processor declarations from " + classesDir + ". Gradle will assume that all processors in this directory are non-incremental.", logStackTraces ? e : null);
return toProcessorDeclarations(processorClassNames, Collections.emptyMap());
}
} catch (Exception e) {
logger.warn("Could not read annotation processor declarations from " + classesDir + ". Gradle will assume that this directory contains no annotation processors.", logStackTraces ? e : null);
return Collections.emptyList();
}
}
private List<String> getProcessorClassNames(File classesDir) throws IOException {
File processorDeclaration = new File(classesDir, PROCESSOR_DECLARATION);
if (!processorDeclaration.isFile()) {
return Collections.emptyList();
}
return readLines(processorDeclaration);
}
private Map<String, IncrementalAnnotationProcessorType> getProcessorTypes(File classesDir) throws IOException {
File incrementalProcessorDeclaration = new File(classesDir, INCREMENTAL_PROCESSOR_DECLARATION);
if (!incrementalProcessorDeclaration.isFile()) {
return Collections.emptyMap();
}
List<String> lines = readLines(incrementalProcessorDeclaration);View on GitHub (pinned to 534f27719b)
Solutions
- Run with --stacktrace to see the underlying exception and identify the failing file
- Clean and rebuild the project that produces the classes directory
- Check filesystem permissions and antivirus exclusions on the build output directory
- If the dir comes from another build tool, package the processor as a jar instead of shipping an exploded dir
Example fix
# before: unreadable declaration file -> directory assumed processor-free ls libs/processor-classes/META-INF/services/javax.annotation.processing.Processor # file exists but is locked/corrupt # after: rebuild restores a readable declaration ./gradlew :processor:clean :processor:compileJava
Defensive patterns
Strategy: validation
Validate before calling
// guard: every processor classes dir must expose a readable, non-empty declaration
def dir = file('libs/processor-classes')
def decl = new File(dir, 'META-INF/services/javax.annotation.processing.Processor')
assert decl.isFile() && decl.canRead() : "unreadable processor declaration in ${dir}"
assert decl.readLines().any { it.trim() && !it.startsWith('#') } : "empty processor declaration in ${dir}" Prevention
- Do not mutate classes directories while a build is scanning them; publish jars instead
- Exclude build output directories from antivirus real-time scanning on Windows
- Run ./gradlew clean after interrupted builds to discard half-written outputs
When it happens
Trigger: The outer catch fires because reading the processor declaration from the classes dir throws: permission problems, concurrent truncation of the directory while Gradle scans it, or a malformed/encoding-broken declaration file.
Common situations: Classes dirs mutated by a concurrent build or file sync (Docker/rsync) during scanning; antivirus or permissions blocking reads on Windows; corrupted build outputs after a killed daemon or interrupted build.
Related errors
- Could not read annotation processor declarations from {}. Gr
- Could not read annotation processor declarations from {}. Gr
- Annotation processor '{}' not found
- Could not instantiate annotation processor '{}'
- Cannot specify -processorpath or --processor-path via `Compi
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/fdbbce03f8083c68.
Report an issue: GitHub.