bumptech/glide · error · IllegalArgumentException
@GlideOption methods must take a BaseRequestOptions<?> objec
Error message
@GlideOption methods must take a BaseRequestOptions<?> object as their first parameter, but {} has none What it means
Every @GlideOption method receives the RequestOptions instance it mutates as its first parameter, so Glide can pass the cloned/locked object through. validateGlideOptionParameters throws when executableElement.getParameters() is empty — there is no RequestOptions to operate on.
Source
Thrown at annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java:120
"@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()) {
throw new IllegalArgumentException(
"@GlideOption methods must take a "
+ "BaseRequestOptions<?> object as their first parameter, but "
+ getQualifiedMethodName(executableElement)
+ " has none");
}
VariableElement first = executableElement.getParameters().get(0);
TypeMirror expected = first.asType();
if (!isBaseRequestOptions(expected)) {
throw new IllegalArgumentException(
"@GlideOption methods must take a"
+ " BaseRequestOptions<?> object as their first parameter, but the first parameter"
+ " in "
+ getQualifiedMethodName(executableElement)
+ " is "
+ expected);
}
}
View on GitHub (pinned to eb14a895d8)
Solutions
- Add a leading parameter of type RequestOptions (or the generated RequestOptions subclass) to the method and operate on it.
- Return that same instance after chaining: `public static RequestOptions cache(RequestOptions options) { return options.diskCacheStrategy(ALL); }`.
Example fix
// before
@GlideOption
public static RequestOptions noCache() {
return new RequestOptions().diskCacheStrategy(NONE);
}
// after
@GlideOption
public static RequestOptions noCache(RequestOptions options) {
return options.diskCacheStrategy(DiskCacheStrategy.NONE);
} Defensive patterns
Strategy: validation
Validate before calling
@Test void glideOptionMethodsHaveRequestOptionsFirstParam() throws Exception {
for (java.lang.reflect.Method m : MyGlideExtension.class.getDeclaredMethods()) {
if (m.isAnnotationPresent(com.bumptech.glide.annotation.GlideOption.class)) {
assertTrue("@GlideOption needs >=1 param: " + m, m.getParameterCount() >= 1);
assertEquals("first param must be RequestOptions: " + m,
com.bumptech.glide.request.RequestOptions.class, m.getParameterTypes()[0]);
}
}
} Prevention
- Always start @GlideOption methods with `RequestOptions options`.
- Use a code template/IDE live template that pre-fills the RequestOptions first parameter.
When it happens
Trigger: GlideExtensionValidator.validateGlideOptionParameters: `if (executableElement.getParameters().isEmpty()) throw`. Hit by a no-arg @GlideOption method like `@GlideOption public static RequestOptions cache() { ... }`.
Common situations: Writing a factory-style helper (`@GlideOption public static RequestOptions noCache() { return new RequestOptions(); }`) instead of an instance-extending method; forgetting the leading RequestOptions parameter when copying an example.
Related errors
- @GlideOption methods must take a BaseRequestOptions<?> objec
- @GlideOption methods should return a BaseRequestOptions<?> o
- Accidentally attempting to override a method in BaseRequestO
- Requested to override an existing method in BaseRequestOptio
- @GlideType methods must take a RequestBuilder object as thei
AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14).
Data as JSON: /api/errors/528d0a0d68919d59.
Report an issue: GitHub.