dagger icon indicating copy to clipboard operation
dagger copied to clipboard

[Bug] Dagger fails and gives an unhelpful error message when trying to inject a class with no injectable members

Open cable729 opened this issue 11 years ago • 3 comments

I am using a method to inject fragments, and some don't have any dependencies (and thus don't have any @Inject fields or constructors). It would be awesome if Dagger would continue when trying to inject a class without an @Inject annotation.

I have been debugging for some time trying to figure this out. I also would suggest changing this error message:

java.lang.IllegalStateException: Unable to create binding for com.example.type

at Linker.java:147 to something like a log message, and changing it to something like

no injectable members found in com.example.type

cable729 avatar Mar 12 '14 01:03 cable729

It would be awesome if Dagger would continue when trying to inject a class without an @Inject annotation.

If the type is listed in a module's injects this should work. It does for me, as far as I can tell.

JakeWharton avatar Mar 12 '14 01:03 JakeWharton

Whoops. Bad habit of reply+close :)

JakeWharton avatar Mar 12 '14 01:03 JakeWharton

@JakeWharton Interesting, that's not how it's working for me. I'll see if I can get it down to a minimal reproducable state.

cable729 avatar Mar 12 '14 16:03 cable729