-
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
Conflicting documentation for dagger.android and Hilt optional inject #4232
Comments
Sorry I'm not entirely following. Aren't the |
Hilt docs have a code snippet with
Furthermore, even if it was like you say, let's say we want to follow I edited OP to try and make this more clear |
Ooh I got it now, thanks. This is a good question! This is actually fairly tricky, but I think to do it you for an Activity you would want to register an I can update the documentation, thanks for pointing this out! |
Fixes #4232. RELNOTES=n/a PiperOrigin-RevId: 609871095
https://dagger.dev/dev-guide/android.html#when-to-inject says:
while https://dagger.dev/hilt/optional-inject.html has this code snippet:
(it was also mentioned in #2132 (comment))
So this means having:
But isn't that a problem if you call
AndroidInjection.inject(this)
(orAndroidSupportInjection.inject(this)
) aftersuper.onCreate
(orsuper.onAttach
)? (Like it says it is crucial to avoid it indagger.android
docs). I can't reproduce the problem now, but I seem to remember that I've seen those issues in the past.On the other hand, if you do it like in
dagger.android
docs, it simply doesn't work at all, so...The text was updated successfully, but these errors were encountered: