{"record":{"id":"aef7d98a4f76e2a6","repo":"bumptech/glide","slug":"unable-to-instantiate-glidemodule-implementation-f","errorCode":null,"errorMessage":"Unable to instantiate GlideModule implementation for {clazz}","messagePattern":"Unable to instantiate GlideModule implementation for (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/bumptech/glide/module/ManifestParser.java","lineNumber":105,"sourceCode":"      // These can't be combined until API minimum is 19.\n    } catch (InstantiationException e) {\n      throwInstantiateGlideModuleException(clazz, e);\n    } catch (IllegalAccessException e) {\n      throwInstantiateGlideModuleException(clazz, e);\n    } catch (NoSuchMethodException e) {\n      throwInstantiateGlideModuleException(clazz, e);\n    } catch (InvocationTargetException e) {\n      throwInstantiateGlideModuleException(clazz, e);\n    }\n\n    if (!(module instanceof GlideModule)) {\n      throw new RuntimeException(\"Expected instanceof GlideModule, but found: \" + module);\n    }\n    return (GlideModule) module;\n  }\n\n  private static void throwInstantiateGlideModuleException(Class<?> clazz, Exception e) {\n    throw new RuntimeException(\"Unable to instantiate GlideModule implementation for \" + clazz, e);\n  }\n}\n","sourceCodeStart":87,"sourceCodeEnd":108,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/library/src/main/java/com/bumptech/glide/module/ManifestParser.java#L87-L108","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nclass MyGlideModule(private val cacheDir: File) : GlideModule { /* ... */ }\n\n// after\nclass MyGlideModule : GlideModule {\n  override fun registerComponents(context: Context, glide: Glide, registry: Registry) {\n    val cacheDir = context.cacheDir // obtain lazily, not in constructor\n  }\n}","handlingStrategy":"validation","validationCode":"val ctor = clazz.getDeclaredConstructor()\nrequire(Modifier.isPublic(ctor.modifiers)) { \"GlideModule needs public no-arg ctor\" }\nrequire(!Modifier.isAbstract(clazz.modifiers)) { \"GlideModule must be concrete\" }\nctor.newInstance() // validate it constructs without throwing","typeGuard":null,"tryCatchPattern":"try {\n  ManifestParser(ctx).parse()\n} catch (e: RuntimeException) {\n  // e.cause reveals Instantiation/IllegalAccess/NoSuchMethod/InvocationTarget\n  logAndFallback(e)\n}","preventionTips":["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"],"tags":["android","glide","manifest","reflection","constructor","proguard"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}