{"record":{"id":"2201b23d9e44d55b","repo":"bumptech/glide","slug":"unrecognized-type","errorCode":null,"errorMessage":"Unrecognized type: {}","messagePattern":"Unrecognized type: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/AppModuleGenerator.java","lineNumber":264,"sourceCode":"    for (Element enclosed : appGlideModuleType.getEnclosedElements()) {\n      if (enclosed.getKind() == ElementKind.CONSTRUCTOR) {\n        ExecutableElement constructor = (ExecutableElement) enclosed;\n        List<? extends VariableElement> parameters = constructor.getParameters();\n        if (parameters.isEmpty()) {\n          return false;\n        } else if (parameters.size() > 1) {\n          throw new IllegalStateException(\n              \"Constructor for \"\n                  + appGlideModule\n                  + \" accepts too many parameters\"\n                  + \", it should accept no parameters, or a single Context\");\n        } else {\n          VariableElement parameter = parameters.get(0);\n          TypeMirror parameterType = parameter.asType();\n          TypeMirror contextType =\n              processingEnv.getElementUtils().getTypeElement(\"android.content.Context\").asType();\n          if (!processingEnv.getTypeUtils().isSameType(parameterType, contextType)) {\n            throw new IllegalStateException(\"Unrecognized type: \" + parameterType);\n          }\n          return true;\n        }\n      }\n    }\n    return false;\n  }\n\n  private MethodSpec generateConstructor(\n      ClassName appGlideModule,\n      Collection<String> libraryGlideModuleClassNames,\n      Collection<String> excludedGlideModuleClassNames) {\n    MethodSpec.Builder constructorBuilder =\n        MethodSpec.constructorBuilder()\n            .addModifiers(Modifier.PUBLIC)\n            .addParameter(\n                ParameterSpec.builder(ClassName.get(\"android.content\", \"Context\"), \"context\")\n                    .build());","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/AppModuleGenerator.java#L246-L282","documentation":"Thrown by the same constructor scan as error 0, but only when your AppGlideModule has exactly one constructor parameter whose type is not android.content.Context. The processor supports only a single Context argument (anything else is ambiguous for code generation), so it refuses to generate the constructor call. The offending type name is appended to the message.","triggerScenarios":"AppModuleGenerator line 263: processingEnv.getTypeUtils().isSameType(parameterType, contextType) returns false for the sole parameter, where contextType is android.content.Context. Hit by e.g. `public MyAppGlideModule(Application app)` (Application is not the same type as Context) or `public MyAppGlideModule(String tag)`.","commonSituations":"Using android.app.Application (a Context subclass, but isSameType is strict equality, not assignability) as the constructor argument; passing a wrapper like ContextWrapper; passing a custom interface or a String tag.","solutions":["Change the single constructor parameter to exactly android.content.Context.","If you currently take Application, switch to Context and cast to Application inside the body only if strictly required (`(Application) context.getApplicationContext()`).","Prefer a no-arg constructor and obtain Context from the registerComponents/applyOptions callbacks that already receive it."],"exampleFix":"// before\n@GlideModule\npublic class MyAppGlideModule extends AppGlideModule {\n  public MyAppGlideModule(Application app) { ... }\n}\n\n// after\n@GlideModule\npublic class MyAppGlideModule extends AppGlideModule {\n  public MyAppGlideModule(Context context) { ... }\n  // or simply omit the constructor\n}","handlingStrategy":"validation","validationCode":"@Test void appGlideModuleSingleParamIsContext() throws Exception {\n  for (java.lang.reflect.Constructor<?> c : MyAppGlideModule.class.getDeclaredConstructors()) {\n    Class<?>[] p = c.getParameterTypes();\n    if (p.length == 1 && p[0] != android.content.Context.class) {\n      throw new AssertionError(\"Sole constructor param must be Context, got \" + p[0]);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exactly android.content.Context, not Application or ContextWrapper.","Prefer a no-arg constructor and obtain Context from the lifecycle callbacks.","Add a unit test asserting the constructor signature so regressions are caught before the Glide processor runs."],"tags":["glide","annotation-processing","appglidemodule","constructor","context"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}