bumptech/glide · error · IllegalArgumentException
@GlideOption methods should return a BaseRequestOptions<?> o
Error message
@GlideOption methods should return a BaseRequestOptions<?> object, but {} returns {}. If you're using old style @GlideOption methods, your method may have a void return type, but doing so is deprecated and support will be removed in a future version What it means
@GlideOption methods must return a BaseRequestOptions<?> (RequestOptions is the concrete subclass generated code chains on). Returning anything else — String, void (the deprecated old style), Integer, etc. — breaks the generated fluent API. validateGlideOption checks isBaseRequestOptions(returnType) and includes the actual return type plus the deprecated-void note in the message.
Source
Thrown at annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java:101
"RequestOptionsExtensions must be public, with private constructors and only static"
+ " methods. Found a non-private constructor in: "
+ getEnclosingClassName(element));
}
ExecutableElement executableElement = (ExecutableElement) element;
if (!executableElement.getParameters().isEmpty()) {
throw new IllegalArgumentException(
"RequestOptionsExtensions must be public, with private constructors and only static"
+ " methods. Found parameters in the constructor of: "
+ getEnclosingClassName(element));
}
}
private void validateGlideOption(ExecutableElement executableElement) {
validateGlideOptionAnnotations(executableElement);
validateGlideOptionParameters(executableElement);
TypeMirror returnType = executableElement.getReturnType();
if (!isBaseRequestOptions(returnType)) {
throw new IllegalArgumentException(
"@GlideOption methods should return a"
+ " BaseRequestOptions<?> object, but "
+ getQualifiedMethodName(executableElement)
+ " returns "
+ returnType
+ ". If you're using old style @GlideOption methods, your"
+ " method may have a void return type, but doing so is deprecated and support will"
+ " be removed in a future version");
}
validateGlideOptionOverride(executableElement);
}
private void validateGlideOptionAnnotations(ExecutableElement executableElement) {
validateAnnotatedNonNull(executableElement);
}
private void validateGlideOptionParameters(ExecutableElement executableElement) {
if (executableElement.getParameters().isEmpty()) {View on GitHub (pinned to eb14a895d8)
Solutions
- Change the @GlideOption method to return RequestOptions (or its generated GlideOptions) and end with `return options;`.
- Ensure the chain on `options` returns the same RequestOptions instance — `return options.centerCrop().placeholder(R.drawable.foo);`.
- If you intended the deprecated void style, be aware it is no longer supported in this version; migrate to the returning style.
Example fix
// before
@GlideOption
public static void cache(RequestOptions options) {
options.diskCacheStrategy(DiskCacheStrategy.ALL);
}
// after
@GlideOption
public static RequestOptions cache(RequestOptions options) {
return options.diskCacheStrategy(DiskCacheStrategy.ALL);
} Defensive patterns
Strategy: type-guard
Type guard
// Compile-time type safety: declare the method signature to return RequestOptions.
// The Kotlin/Java compiler then guarantees a BaseRequestOptions<?> return.
@GlideOption
public static RequestOptions myOption(RequestOptions options) {
return options.centerCrop(); // same type, no accidental void/foreign return
} Prevention
- Always `return options;` (the same instance, chained) at the end of a @GlideOption method.
- Declare the return type as RequestOptions so the compiler rejects void/foreign returns.
- Migrate any legacy void-style options to the returning style.
When it happens
Trigger: GlideExtensionValidator.validateGlideOption reads executableElement.getReturnType(); if it is not assignable to com.bumptech.glide.request.BaseRequestOptions<?> (legacy string compare or erased-element compare per useLegacyTypeComparison), it throws. Hit by returning `void`, `String`, `Drawable`, or a custom type from a @GlideOption method.
Common situations: Porting old Glide v3 void-style options to the new API but forgetting to `return options`; chaining helpers that accidentally return a sub-result (`options.transform()` whose generic is fine, but returning a builder of a different type); returning `RequestBuilder` instead of `RequestOptions`.
Related errors
- @GlideOption methods must take a BaseRequestOptions<?> objec
- @GlideOption methods must take a BaseRequestOptions<?> objec
- Accidentally attempting to override a method in BaseRequestO
- Requested to override an existing method in BaseRequestOptio
- @GlideType methods should return a RequestBuilder<{}> object
AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14).
Data as JSON: /api/errors/77612c7b54d6ec09.
Report an issue: GitHub.