dagger icon indicating copy to clipboard operation
dagger copied to clipboard

Unclear error message when module injects= includes an interface.

Open pforhan opened this issue 11 years ago • 4 comments

I changed LandingScreen.LandingView from a class to an interface, but forgot to update the module with the new concrete class. You can't inject an interface, the error should say something to that effect:

.../LandingScreen.java:[77,17] LandingScreen$LandingView could not be
 bound with key LandingScreen$LandingView required by 
LandingScreen.Module for LandingScreen.Module

pforhan avatar May 08 '14 19:05 pforhan

You can inject an interface but nothing was providing its type. The error message looks correct.

JakeWharton avatar May 08 '14 21:05 JakeWharton

(Granted, most of Dagger's errors could use more human terms)

JakeWharton avatar May 08 '14 21:05 JakeWharton

Recommendations on messaging improvements are gratefully appreciated. :D That said, when we start looking hard at the 2.0 first-cut, we can take the opportunity to critique the messaging wholesale.

cgruber avatar May 09 '14 01:05 cgruber

Just to clarify, here was the problem module:

  @dagger.Module(injects = {
      LandingView.class
  })
  public static class Module {
  }

The error message needs to give some sort of hint about how to fix the problem. Does it ever make sense to put an interface up there?

pforhan avatar May 09 '14 12:05 pforhan