bumptech/glide · error · IllegalArgumentException
The {} method annotated with @GlideOption in the {} @GlideEx
Error message
The {} method annotated with @GlideOption in the {} @GlideExtension is using a legacy format that is no longer supported. Please change your method definition so that your @GlideModule annotated methods return BaseRequestOptions<?> objects instead of null. What it means
Thrown when generating code for a method annotated with @GlideOption inside a @GlideExtension whose return type is void. The current Glide API requires @GlideOption methods to return a BaseRequestOptions<?> (typically the modified options object); the older void-returning signature is no longer supported.
Source
Thrown at annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsExtensionGenerator.java:61
* Returns a list containing an override {@link MethodSpec} for all {@link GlideOption} annotated
* methods in the classes that correspond to the given extension class names.
*/
List<MethodSpec> generateInstanceMethodsForExtensions(Set<String> glideExtensionClassNames) {
List<ExecutableElement> requestOptionExtensionMethods =
getRequestOptionExtensionMethods(glideExtensionClassNames);
List<MethodSpec> result = new ArrayList<>(requestOptionExtensionMethods.size());
for (ExecutableElement requestOptionsExtensionMethod : requestOptionExtensionMethods) {
result.add(generateMethodsForRequestOptionsExtension(requestOptionsExtensionMethod));
}
return result;
}
private MethodSpec generateMethodsForRequestOptionsExtension(ExecutableElement element) {
// Assert for legacy versions
if (element.getReturnType().getKind() == TypeKind.VOID) {
throw new IllegalArgumentException(
"The "
+ element.getSimpleName()
+ " method annotated with @GlideOption in the "
+ element.getEnclosingElement().getSimpleName()
+ " @GlideExtension is using a legacy"
+ " format that is no longer supported. Please change your method definition so that"
+ " your @GlideModule annotated methods return BaseRequestOptions<?> objects instead"
+ " of null.");
}
int overrideType = processorUtil.getOverrideType(element);
String methodName = element.getSimpleName().toString();
MethodSpec.Builder builder =
MethodSpec.methodBuilder(methodName)
.addModifiers(Modifier.PUBLIC)
.addJavadoc(processorUtil.generateSeeMethodJavadoc(element))
.varargs(element.isVarArgs())View on GitHub (pinned to eb14a895d8)
Solutions
- Change the @GlideOption method to return BaseRequestOptions<?> (e.g. RequestOptions or GlideOptions).
- Return the options object at the end of the method after applying your customization.
- Update the method signature so the first parameter is the RequestOptions/BaseRequestOptions instance.
- Rebuild; the processor will now generate the static helper.
Example fix
// before
@GlideOption
@GlideExtension
fun cache( options: RequestOptions) {
options.diskCacheStrategy(DiskCacheStrategy.ALL)
}
// after
@GlideOption
@GlideExtension
fun cache(options: RequestOptions): RequestOptions {
return options.diskCacheStrategy(DiskCacheStrategy.ALL)
} Defensive patterns
Strategy: validation
Validate before calling
// @GlideOption methods must return BaseRequestOptions<?>, not void.
@GlideOption
fun myOption(options: RequestOptions): RequestOptions {
return options.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
} Prevention
- Always return the options object from @GlideOption methods.
- Keep the first parameter as the RequestOptions/BaseRequestOptions instance.
- Update extension code copied from old Glide samples to the modern signature.
When it happens
Trigger: generateMethodsForRequestOptionsExtension() inspects element.getReturnType().getKind(); if it is TypeKind.VOID the legacy-format guard fires. This happens for any @GlideOption extension method declared with a void return.
Common situations: Porting a project or sample from an old Glide version (<=3.x or early 4.x previews) whose @GlideOption methods returned void; copy-pasting an outdated Glide extension example; following a stale tutorial.
Related errors
- Expected non-empty parameters for: {}
- Failed to find value for: {} from mirrors: {}
- Unresolved class type in annotation: {}
- Unrecognized static method name: {}
- RequestOptionsExtensions must be public, including: {}
AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14).
Data as JSON: /api/errors/fbf5db4c57da450b.
Report an issue: GitHub.