{"record":{"id":"aae6b9fb54351d83","repo":"bumptech/glide","slug":"you-cannot-have-more-than-one-appglidemodule-foun","errorCode":null,"errorMessage":"You cannot have more than one AppGlideModule, found: {}","messagePattern":"You cannot have more than one AppGlideModule, found: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/AppModuleProcessor.java","lineNumber":58,"sourceCode":"    requestOptionsGenerator = new RequestOptionsGenerator(processingEnv, processorUtil);\n    requestManagerGenerator = new RequestManagerGenerator(processingEnv, processorUtil);\n    requestManagerFactoryGenerator =\n        new RequestManagerFactoryGenerator(processingEnv, processorUtil);\n    glideGenerator = new GlideGenerator(processingEnv, processorUtil);\n    requestBuilderGenerator = new RequestBuilderGenerator(processingEnv, processorUtil);\n  }\n\n  void processModules(Set<? extends TypeElement> set, RoundEnvironment env) {\n    for (TypeElement element : processorUtil.getElementsFor(GlideModule.class, env)) {\n      if (processorUtil.isAppGlideModule(element)) {\n        appGlideModules.add(element);\n      }\n    }\n\n    processorUtil.debugLog(\"got app modules: \" + appGlideModules);\n\n    if (appGlideModules.size() > 1) {\n      throw new IllegalStateException(\n          \"You cannot have more than one AppGlideModule, found: \" + appGlideModules);\n    }\n  }\n\n  boolean maybeWriteAppModule() {\n    // appGlideModules is added to in order to catch errors where multiple AppGlideModules may be\n    // present for a single application or library. Because we only add to appGlideModules, we use\n    // isGeneratedAppGlideModuleWritten to make sure the GeneratedAppGlideModule is written at\n    // most once.\n    if (appGlideModules.isEmpty()) {\n      return false;\n    }\n    TypeElement appModule = appGlideModules.get(0);\n    processorUtil.debugLog(\"Processing app module: \" + appModule);\n    // If this package is null, it means there are no classes with this package name. One way this\n    // could happen is if we process an annotation and reach this point without writing something\n    // to the package. We do not error check here because that shouldn't happen with the\n    // current implementation.","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/AppModuleProcessor.java#L40-L76","documentation":"Glide permits at most one AppGlideModule per application because the generated entry point (GlideApp) and the merged module are singletons keyed off it. AppModuleProcessor.processModules collects every @GlideModule-annotated class that is an AppGlideModule and throws when the set size exceeds one. The full list of offending classes is printed so you can locate the duplicates.","triggerScenarios":"AppModuleProcessor.processModules iterates processorUtil.getElementsFor(GlideModule.class, env), adds each isAppGlideModule(element) to appGlideModules, and throws when appGlideModules.size() > 1. Hit when the compilation contains two @GlideModule classes extending AppGlideModule, including one pulled in transitively from an AAR's generated sources or from a copied sample.","commonSituations":"Copying Glide's sample MyAppGlideModule into your app while a library module already declares one; merging modules from two products/flavors without excluding one; an old manifest-based AppGlideModule lingering alongside a new annotated one; an AAR you depend on shipping an AppGlideModule (which is itself a packaging bug in that AAR).","solutions":["Search the whole module graph (app + all AAR deps) for classes extending AppGlideModule annotated with @GlideModule and keep exactly one.","If a duplicate comes from a library/AAR, file a bug against that library — only the application module should declare an AppGlideModule.","If it comes from a product-flavor or buildVariant split, move the AppGlideModule into a source set shared by all variants or guard duplicates with flavor-specific sourceSet exclusions.","Remove any stale hand-written com.bumptech.glide.AppGlideModule subclass left from a manifest-based migration."],"exampleFix":"// before — two classes in the compilation\n@GlideModule public class AppGlideModuleA extends AppGlideModule { ... }\n@GlideModule public class AppGlideModuleB extends AppGlideModule { ... }\n\n// after — keep a single AppGlideModule\n@GlideModule public class AppGlideModuleA extends AppGlideModule { ... }\n// delete AppGlideModuleB","handlingStrategy":"validation","validationCode":"// In a build-time check (e.g. a gradle task or test), scan the classpath for AppGlideModules:\n@Test void atMostOneAppGlideModule() throws Exception {\n  long count = java.util.stream.Stream.of(new java.io.File(\"build/intermediates/javac/debug/classes\").listFiles())\n      .filter(f -> f.getName().endsWith(\".class\")).count(); // illustrative\n  // Better: enforce in code review that exactly one @GlideModule extends AppGlideModule exists.\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep exactly one AppGlideModule in the application module; libraries must never declare one.","When adding an AAR dependency, verify it does not bundle an AppGlideModule.","Use product-flavor source sets to avoid duplicating the AppGlideModule across variants."],"tags":["glide","annotation-processing","appglidemodule","duplicate"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}