bumptech/glide · error · IllegalArgumentException
Given both modules and extensions, expected one or the other
Error message
Given both modules and extensions, expected one or the other. Modules: {} Extensions: {} What it means
Each generated Indexer class bundles either modules OR extensions, never both, because they are indexed separately downstream. IndexerGenerator.generate throws when, after classification, both the `modules` and `extensions` lists are non-empty for the same indexer batch — an internal invariant violation indicating mixed classification input.
Source
Thrown at annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/IndexerGenerator.java:71
IndexerGenerator(ProcessorUtil processorUtil) {
this.processorUtil = processorUtil;
}
TypeSpec generate(List<TypeElement> types) {
List<TypeElement> modules = new ArrayList<>();
List<TypeElement> extensions = new ArrayList<>();
for (TypeElement element : types) {
if (processorUtil.isExtension(element)) {
extensions.add(element);
} else if (processorUtil.isLibraryGlideModule(element)) {
modules.add(element);
} else {
throw new IllegalArgumentException("Unrecognized type: " + element);
}
}
if (!modules.isEmpty() && !extensions.isEmpty()) {
throw new IllegalArgumentException(
"Given both modules and extensions, expected one or the "
+ "other. Modules: "
+ modules
+ " Extensions: "
+ extensions);
}
if (!modules.isEmpty()) {
return generate(types, GlideModule.class);
} else {
return generate(types, GlideExtension.class);
}
}
private TypeSpec generate(
List<TypeElement> libraryModules, Class<? extends Annotation> annotation) {
// Sort modules by qualified name to ensure deterministic ordering
List<TypeElement> sortedModules = new ArrayList<>(libraryModules);
sortedModules.sort(Comparator.comparing(a -> a.getQualifiedName().toString()));View on GitHub (pinned to eb14a895d8)
Solutions
- Inspect the printed modules/extensions lists and ensure no class is both a LibraryGlideModule and a @GlideExtension — split them.
- Clean and rebuild to rule out stale indexer inputs.
- Align Glide dependency versions across modules.
Defensive patterns
Strategy: validation
Prevention
- Never make a single class both a LibraryGlideModule and a @GlideExtension.
- Keep library modules and extensions in separate classes.
- Clean and align Glide versions if the error appears without an obvious cause.
When it happens
Trigger: IndexerGenerator.generate: `if (!modules.isEmpty() && !extensions.isEmpty()) throw`. Reached only if the same batch contains elements classified as both a LibraryGlideModule and a GlideExtension — which should not happen for well-formed classes (a class cannot validly be both).
Common situations: A class that somehow has both @GlideExtension and extends LibraryGlideModule (or is detected as both); a custom/buggy annotation setup; incremental cache feeding a mixed batch; an upstream Glide bug.
Related errors
- Unrecognized type: {}
- Unrecognized annotation: {}
- Cannot process annotations after writing AppGlideModule
- Expected single value, but found: {}
- Constructor for {} accepts too many parameters, it should ac
AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14).
Data as JSON: /api/errors/9a65ac81c8e5a0ba.
Report an issue: GitHub.