-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IllegalStateException in BuildingGraphValidator (475) #123
Comments
A basic example:
The idea for this is that some objects will use an application level context (mainly singletons like Volley) while others might need just the local context (Some business logic class in a fragment). Ideally I'd just be able to specify which I'd like via:
or
|
Looking at your example, I think you're conflating two concepts - scope and qualification, and are doing so because Android is insane and uses the Context API for both application-level things and activity-level things. I recommend you either supply ... or (my recommendation) just drop using Context as a type, and bind Application and Activity, since nearly every usage where you'd consume these will either need to know one from the other, or won't care and will behave correctly for any Context, and so you can feed those methods the appropriate context yourself. Then you don't have a lot of As to scope validation, I think your problem will likely go away if you use When attached to the type of a component interface, that scope annotation represents a constraint such that all bindings reachable by that component (either via included modules, or implicitly via
A scope annotation can also go on a
This signals to dagger that these bindings in question are to be memoized in the component that was marked with Scope in Dagger is far less automagical than in Guice or Spring. Lifetimes are determined by the lifetime of the component's instance - what you get from the component builder. |
All that said, we shouldn't have illegal state exceptions, we should have proper compiler errors. Can you please provide a stack-trace so we can figure out what check we're letting slip through? |
We have had several updates since this but was filed - for now I'll close it. Feel free to re-open it if you can replicate the behavior with the latest snapshot. |
I'm attempting to compile my project and it's running into an IllegalStateException in the BuildingGraphValidator on line 475. There's no error message in that exception so I'm not really sure what's failing or why.
Looking at the code it looks like it has to do with validating the scope of the components. I do know that I have a component of scope A depending on a component of scope B (basically one is a singelton-level scope and the other is an activity-level scope). I'm going to guess that the issue is a misplaced or missing scope annotation, but the error message is blank so it doesn't give much of an indicator.
The text was updated successfully, but these errors were encountered: