bumptech/glide · error · IllegalArgumentException

Expected single value, but found: {}

Error message

Expected single value, but found: {}

What it means

ProcessorUtil.findClassValuesFromAnnotationOnClassAsNames (used to read @Excludes and similar single-value class-array annotations) expects the matched AnnotationMirror to expose exactly one element value (the `value()` member). If the mirror has zero or more than one element-value entry, the processor cannot decide which entry holds the class list and throws defensively.

Source

Thrown at annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/ProcessorUtil.java:553

        .filter(new FilterPublicMethods((TypeMirror) null /*returnType*/, MethodType.STATIC))
        .transform(new ToMethod())
        .toList();
  }

  ImmutableSet<String> findClassValuesFromAnnotationOnClassAsNames(
      Element clazz, Class<? extends Annotation> annotationClass) {
    String annotationClassName = annotationClass.getName();
    AnnotationValue excludedModuleAnnotationValue = null;
    for (AnnotationMirror annotationMirror : clazz.getAnnotationMirrors()) {
      // Two different AnnotationMirrors the same class might not be equal, so compare Strings
      // instead. This check is necessary because a given class may have multiple Annotations.
      if (!annotationClassName.equals(annotationMirror.getAnnotationType().toString())) {
        continue;
      }

      var entries = annotationMirror.getElementValues().entrySet();
      if (entries.size() != 1) {
        throw new IllegalArgumentException("Expected single value, but found: " + entries);
      }
      excludedModuleAnnotationValue = entries.iterator().next().getValue();
      if (excludedModuleAnnotationValue == null) {
        throw new IllegalArgumentException(
            "Failed to find value for: "
                + annotationClass
                + " from mirrors: "
                + clazz.getAnnotationMirrors());
      }
    }

    if (excludedModuleAnnotationValue == null) {
      return ImmutableSet.of();
    }

    Object value = excludedModuleAnnotationValue.getValue();
    if (value instanceof List) {
      LinkedHashSet<String> out = new LinkedHashSet<>();

View on GitHub (pinned to eb14a895d8)

Solutions

  1. Always supply the value member explicitly: `@Excludes({SomeModule.class, OtherModule.class})`.
  2. If excluding a single module, still use array syntax: `@Excludes(SomeModule.class)`.
  3. Ensure no other annotation on the same class shares the fully-qualified name being looked up.
  4. Upgrade Kotlin/KAPT and glide:compiler — annotation-mirror iteration edge cases are usually fixed upstream.

Example fix

// before
@Excludes
public class MyAppGlideModule extends AppGlideModule { ... }

// after
@Excludes({SomeLibraryModule.class})
public class MyAppGlideModule extends AppGlideModule { ... }
Defensive patterns

Strategy: validation

Validate before calling

@Test void excludesAnnotationHasSingleValueMember() {
  Excludes ex = MyAppGlideModule.class.getAnnotation(Excludes.class);
  if (ex != null) {
    // The annotation declares exactly one member (value()); ensure it is populated.
    assertTrue("@Excludes must list at least one module", ex.value().length > 0);
  }
}

Prevention

When it happens

Trigger: ProcessorUtil: iterates clazz.getAnnotationMirrors(); for the mirror whose type matches annotationClass.getName(), reads `annotationMirror.getElementValues().entrySet()`; throws when `entries.size() != 1`. Most plausibly hit with @Excludes when the annotation is applied without a value (relying on a default) or when an exotic/derived annotation exposes multiple members and matches the looked-up name.

Common situations: Writing `@Excludes` with no `value = {...}` (the member is required, but a malformed/IDE-assisted declaration can confuse the mirror); a custom annotation that collides in name and exposes multiple members; a Kotlin annotation-use-site quirk that emits an empty value set; edge cases with certain Kotlin/KAPT metadata.

Related errors


AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14). Data as JSON: /api/errors/c1b6be60393e2f8e. Report an issue: GitHub.