bumptech/glide · error · IllegalArgumentException
@GlideType methods must take a RequestBuilder object as thei
Error message
@GlideType methods must take a RequestBuilder object as their first and only parameter, but given: {} for: {} What it means
The single parameter of a @GlideType method must be a RequestBuilder (matching the annotation's `value()` type). validateGlideTypeParameters reads the first parameter's type and throws when it is not a RequestBuilder — legacy path compares by `toString().startsWith("com.bumptech.glide.RequestBuilder")`, modern path uses erased-element equality against com.bumptech.glide.RequestBuilder.
Source
Thrown at annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java:304
TypeMirror toCompare = types.erasure(typeMirror);
return Objects.equals(
types.asElement(toCompare), elements.getTypeElement("com.bumptech.glide.RequestBuilder"));
}
private void validateGlideTypeParameters(ExecutableElement executableElement) {
if (executableElement.getParameters().size() != 1) {
throw new IllegalArgumentException(
"@GlideType methods must take a"
+ " RequestBuilder object as their first and only parameter, but given multiple for: "
+ getQualifiedMethodName(executableElement));
}
VariableElement first = executableElement.getParameters().get(0);
TypeMirror argumentType = first.asType();
if (useLegacyTypeComparison
? !argumentType.toString().startsWith("com.bumptech.glide.RequestBuilder")
: !isRequestBuilder(argumentType)) {
throw new IllegalArgumentException(
"@GlideType methods must take a"
+ " RequestBuilder object as their first and only parameter, but given: "
+ argumentType
+ " for: "
+ getQualifiedMethodName(executableElement));
}
}
private void validateGlideTypeAnnotations(ExecutableElement executableElement) {
validateAnnotatedNonNull(executableElement);
}
private void validateAnnotatedNonNull(ExecutableElement executableElement) {
Set<String> annotationNames =
FluentIterable.from(executableElement.getAnnotationMirrors())
.transform(
new Function<AnnotationMirror, String>() {
@OverrideView on GitHub (pinned to eb14a895d8)
Solutions
- Declare the single parameter as `RequestBuilder<T>` where T matches `@GlideType(T.class)`.
- If you intended to customize RequestOptions, move the method to be a @GlideOption instead and change the parameter to RequestOptions.
Example fix
// before
@GlideType(GifDrawable.class)
public static RequestBuilder<GifDrawable> asGif(RequestOptions options) {
...
}
// after
@GlideType(GifDrawable.class)
public static RequestBuilder<GifDrawable> asGif(RequestBuilder<GifDrawable> requestBuilder) {
...
} Defensive patterns
Strategy: validation
Validate before calling
@Test void glideTypeParamIsRequestBuilder() throws Exception {
for (java.lang.reflect.Method m : MyGlideExtension.class.getDeclaredMethods()) {
if (m.isAnnotationPresent(com.bumptech.glide.annotation.GlideType.class)) {
Class<?> first = m.getParameterTypes()[0];
assertTrue("@GlideType param must be RequestBuilder: " + m + " got " + first,
com.bumptech.glide.RequestBuilder.class.isAssignableFrom(first));
}
}
} Prevention
- Use RequestBuilder<T> for @GlideType and RequestOptions for @GlideOption — never swap them.
- Validate the parameter type in a reflection test.
When it happens
Trigger: GlideExtensionValidator.validateGlideTypeParameters: after the size==1 check, `if (useLegacyTypeComparison ? !argumentType.toString().startsWith("com.bumptech.glide.RequestBuilder") : !isRequestBuilder(argumentType)) throw`. Hit by passing a RequestOptions, Drawable, or any non-RequestBuilder as the sole parameter.
Common situations: Confusing @GlideType (operates on RequestBuilder) with @GlideOption (operates on RequestOptions); passing a raw `RequestBuilder` without the generic; using a custom RequestBuilder subclass not recognized due to legacy comparison.
Related errors
- @GlideType methods must take a RequestBuilder object as thei
- @GlideOption methods must take a BaseRequestOptions<?> objec
- @GlideOption methods must take a BaseRequestOptions<?> objec
- @GlideType methods should return a RequestBuilder<{}> object
- Constructor for {} accepts too many parameters, it should ac
AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14).
Data as JSON: /api/errors/813413e2a2ce42b2.
Report an issue: GitHub.