1

Is there a way to get dagger to spit out why it didn't generate a particular component?

I tried refactoring some of our modules and ended up breaking something, but I have literally no idea what I broke! All I see is that all my DaggerFoo components are missing, because dagger is apparently silently failing.

I've tried compiling with verbosity & higher max errors, but I still see absolutely nothing from Dagger itself saying what went wrong.

-Xdiags:verbose
-Xmaxerrs=1000

I have no relevant errors to share, because none are printed!

How the heck do you debug Dagger2?

  • Java app. I tried the log level from your link, but still no dice. Complete radio silence from Dagger. I've spent a few hours on this, so I'm just going to give up, roll back, and re-introduce my changes one by one T_T – I was in the neighborhood Aug 24 '22 at 20:28
  • @paulsm4 Unfortunately there's a name collision here: https://dagger.io/ is a "a portable devkit for CI/CD pipelines"; OP you were looking for "fully static, compile-time dependency injection framework for Java" documented at https://dagger.dev/. – Jeff Bowman Aug 26 '22 at 18:28
  • @Jeff Bowman - whoops. Thank you! And +1 on your excellent reply below :) – paulsm4 Aug 27 '22 at 00:53

1 Answers1

0

Dagger runs as an annotation processor, so its error messages will manifest as compiler errors. These will often look like this message ("X cannot be provided...").

error: some.injected.ClassName cannot be provided without an @Inject constructor
    or from an @Provides- or @Produces-annotated method.
some.injected.ClassName is injected at
some.class.that.InjectsIt
some.class.that.InjectsThatAbove
some.class.that.FurtherInjectsThat

If you're not sure where to look for compiler errors, you can see some other answers here:

If you've edited your project configuration or Gradle definition, it is also possible that Dagger is no longer running at all, or that it hasn't run for a while and has been working only based on its previous output. If so, check your Gradle file or Eclipse project definition to ensure that you are including Dagger as an annotationProcessor, and that you have at least one @Component file for that annotation processor to find.

Jeff Bowman
  • 90,959
  • 16
  • 217
  • 251