bumptech/glide · error · RuntimeException
Unable to instantiate GlideModule implementation for {clazz}
Error message
Unable to instantiate GlideModule implementation for {clazz} What it means
Thrown by ManifestParser.throwInstantiateGlideModuleException when reflective instantiation of a registered GlideModule class fails. Wraps one of InstantiationException, IllegalAccessException, NoSuchMethodException, or InvocationTargetException, indicating the class itself was found (Class.forName succeeded) but a new instance could not be created.
Source
Thrown at library/src/main/java/com/bumptech/glide/module/ManifestParser.java:105
// These can't be combined until API minimum is 19.
} catch (InstantiationException e) {
throwInstantiateGlideModuleException(clazz, e);
} catch (IllegalAccessException e) {
throwInstantiateGlideModuleException(clazz, e);
} catch (NoSuchMethodException e) {
throwInstantiateGlideModuleException(clazz, e);
} catch (InvocationTargetException e) {
throwInstantiateGlideModuleException(clazz, e);
}
if (!(module instanceof GlideModule)) {
throw new RuntimeException("Expected instanceof GlideModule, but found: " + module);
}
return (GlideModule) module;
}
private static void throwInstantiateGlideModuleException(Class<?> clazz, Exception e) {
throw new RuntimeException("Unable to instantiate GlideModule implementation for " + clazz, e);
}
}
View on GitHub (pinned to eb14a895d8)
Solutions
- Ensure the GlideModule class has a public no-arg constructor and make no-arg construction safe (no I/O, no required args)
- If the module needs config, read it lazily in registerComponents/applyOptions instead of in the constructor
- Add ProGuard keep rules for the constructor: -keepclassmembers class * { public <init>(); }
- Inspect the wrapped cause exception (InvocationTargetException.getCause) to find the real failure inside the constructor
Example fix
// before
class MyGlideModule(private val cacheDir: File) : GlideModule { /* ... */ }
// after
class MyGlideModule : GlideModule {
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
val cacheDir = context.cacheDir // obtain lazily, not in constructor
}
} Defensive patterns
Strategy: validation
Validate before calling
val ctor = clazz.getDeclaredConstructor()
require(Modifier.isPublic(ctor.modifiers)) { "GlideModule needs public no-arg ctor" }
require(!Modifier.isAbstract(clazz.modifiers)) { "GlideModule must be concrete" }
ctor.newInstance() // validate it constructs without throwing Try / catch
try {
ManifestParser(ctx).parse()
} catch (e: RuntimeException) {
// e.cause reveals Instantiation/IllegalAccess/NoSuchMethod/InvocationTarget
logAndFallback(e)
} Prevention
- Give every GlideModule a public no-arg constructor that does no I/O
- Move any risky init into registerComponents/applyOptions where the Context is available
- Keep ProGuard rules that preserve public no-arg constructors on module classes
- Unit-test module instantiation in isolation
When it happens
Trigger: The registered module class has no public no-arg constructor (NoSuchMethodException); the constructor is private or protected (IllegalAccessException); the class is abstract or an interface or an array (InstantiationException); or the no-arg constructor throws an exception at runtime (InvocationTargetException).
Common situations: A GlideModule whose constructor requires arguments (DI-injected config); a module class made abstract by mistake; a constructor that performs work that fails on certain devices/OS versions (e.g. reading a file or initializing a native lib); constructor visibility changed by ProGuard obfuscation.
Related errors
- Unable to find GlideModule implementation
- Expected instanceof GlideModule, but found: {module}
- Constructor for {} accepts too many parameters, it should ac
- Unrecognized type: {}
- RequestOptionsExtensions must be public, with private constr
AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14).
Data as JSON: /api/errors/aef7d98a4f76e2a6.
Report an issue: GitHub.