{"record":{"id":"5284d38a11c0d033","repo":"bumptech/glide","slug":"expected-instanceof-glidemodule-but-found-modul","errorCode":null,"errorMessage":"Expected instanceof GlideModule, but found: {module}","messagePattern":"Expected instanceof GlideModule, but found: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/bumptech/glide/module/ManifestParser.java","lineNumber":99,"sourceCode":"      throw new IllegalArgumentException(\"Unable to find GlideModule implementation\", e);\n    }\n\n    Object module = null;\n    try {\n      module = clazz.getDeclaredConstructor().newInstance();\n      // 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":81,"sourceCodeEnd":108,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/library/src/main/java/com/bumptech/glide/module/ManifestParser.java#L81-L108","documentation":"Thrown by ManifestParser.parseModule after a class named in AndroidManifest meta-data was loaded and instantiated via reflection but does not implement com.bumptech.glide.module.GlideModule. The parser needs the GlideModule contract (registerComponents / applyOptions) to wire in custom behavior.","triggerScenarios":"Registering a plain class, a data holder, or a class implementing a different interface under android:value=\"GlideModule\" in the manifest. The class loads and constructs fine, but fails the instanceof GlideModule check at ManifestParser.java:99.","commonSituations":"Copy-paste of a meta-data entry with the wrong class; a module class that extends a base class which no longer implements GlideModule after a library update; using an AppGlideModule (the new API) name in the old manifest meta-data path.","solutions":["Make the registered class implement (or extend a base that implements) com.bumptech.glide.module.GlideModule","Migrate to the modern @GlideModule + AppGlideModule annotation-processor API and delete the manifest entry","Remove the stale meta-data entry if the class is not meant to be a Glide module","Verify the class has a public no-arg constructor and the correct inheritance after library upgrades"],"exampleFix":"// before\n<meta-data android:name=\"com.example.ConfigHolder\" android:value=\"GlideModule\"/>\n// ConfigHolder is a plain object, not a GlideModule\n\n// after\nclass MyGlideModule : GlideModule {\n  override fun applyOptions(context: Context, builder: GlideBuilder) { /* ... */ }\n  override fun registerComponents(context: Context, glide: Glide, registry: Registry) { /* ... */ }\n}","handlingStrategy":"type-guard","validationCode":"val module: Any = clazz.getDeclaredConstructor().newInstance()\nrequire(module is GlideModule) { \"${clazz.name} is not a GlideModule\" }","typeGuard":"fun isGlideModule(clazz: Class<*>): Boolean =\n  com.bumptech.glide.module.GlideModule::class.java.isAssignableFrom(clazz)","tryCatchPattern":null,"preventionTips":["Ensure every class registered under android:value=\"GlideModule\" implements GlideModule","Prefer the annotation-processor @GlideModule API which enforces the type at compile time","Add a CI check that scans AndroidManifest meta-data entries against the source set"],"tags":["android","glide","manifest","reflection","type-mismatch"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}