{"record":{"id":"01d4c0032548c538","repo":"bumptech/glide","slug":"cannot-process-annotations-after-writing-appglidem","errorCode":null,"errorMessage":"Cannot process annotations after writing AppGlideModule","messagePattern":"Cannot process annotations after writing AppGlideModule","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideAnnotationProcessor.java","lineNumber":130,"sourceCode":"   *   <li>Find all {@code LibraryGlideModule}s\n   *   <li>For each {@code LibraryGlideModule}, write an {@code Indexer} with an Annotation with the\n   *       class name.\n   *   <li>If we wrote any {@code Indexer}s, return and wait for the next round.\n   *   <li>If we didn't write any {@code Indexer}s and there is a {@code AppGlideModule}, write the\n   *       {@code GeneratedAppGlideModule}. Once the {@code GeneratedAppGlideModule} is written, we\n   *       expect to be finished. Any further generation of related classes will result in errors.\n   * </ol>\n   */\n  @Override\n  public boolean process(Set<? extends TypeElement> set, RoundEnvironment env) {\n    processorUtil.process();\n    boolean newModulesWritten = libraryModuleProcessor.processModules(env);\n    boolean newExtensionWritten = extensionProcessor.processExtensions(env);\n    appModuleProcessor.processModules(set, env);\n\n    if (newExtensionWritten || newModulesWritten) {\n      if (isGeneratedAppGlideModuleWritten) {\n        throw new IllegalStateException(\"Cannot process annotations after writing AppGlideModule\");\n      }\n      return false;\n    }\n\n    if (!isGeneratedAppGlideModuleWritten) {\n      isGeneratedAppGlideModuleWritten = appModuleProcessor.maybeWriteAppModule();\n    }\n    return false;\n  }\n}\n","sourceCodeStart":112,"sourceCodeEnd":141,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideAnnotationProcessor.java#L112-L141","documentation":"GlideAnnotationProcessor writes the combined GeneratedAppGlideModule only once (tracked by isGeneratedAppGlideModuleWritten) and treats that as a point of no return. If, in a later annotation-processing round, a new LibraryGlideModule or GlideExtension is discovered (newModulesWritten || newExtensionWritten) after the app module was already written, the processor throws rather than emit inconsistent/missing indexer entries. It is an internal ordering invariant violation, not a normal user-annotation mistake.","triggerScenarios":"GlideAnnotationProcessor.process: after libraryModuleProcessor.processModules / extensionProcessor.processExtensions return true in a round following the one where isGeneratedAppGlideModuleWritten became true, the guard `if (newExtensionWritten || newModulesWritten) { if (isGeneratedAppGlideModuleWritten) throw }` fires. Typically triggered by another annotation processor or code generator that emits a @GlideModule/@GlideExtension class in a later round.","commonSituations":"A different processor (Dagger, AutoService, a custom generator) produces a @GlideModule/@GlideExtension in a later round after Glide already wrote its output; incremental/incremental-KAPT misconfiguration causing Glide to run before all sources are visible; an ICE/build-cache corruption that reorders rounds; mixing KSP and KAPT processors on the same module.","solutions":["Clean and rebuild (`./gradlew clean` then build) to rule out stale/incremental state.","Ensure no other annotation processor generates classes annotated with @GlideModule or @GlideExtension.","Disable incremental compilation for the affected module (kapt.use.worker.api=false / kapt.incremental.apt=false) to confirm whether round ordering is the cause, then isolate the offending processor.","Upgrade glide:compiler and kotlin/kapt versions — round-ordering bugs are usually fixed upstream.","Move hand-written @GlideModule/@GlideExtension classes so they are visible in the first processing round (same module, no generated indirection)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not write an annotation processor that generates @GlideModule/@GlideExtension classes.","Keep kapt.incremental.apt and worker-api settings aligned with the Glide version in use.","Run a clean build when you see round-ordering failures to rule out incremental-cache corruption.","Upgrade glide:compiler together with Kotlin/KAPT to pick up round-ordering fixes."],"tags":["glide","annotation-processing","processor-rounds","internal"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}