-
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
Dagger does not support providing @AssistedInject types #2396
Comments
Duplicate of #2370? |
@tbroyer is there any way to handle this use case at this time? |
@alizarei95, note that #2370 will allow you to provide a qualified Thus, you'll have to provide your default type with a qualifier like, You probably also want to provide the default via the factory rather than calling the constructor directly. For example: @Module
@InstallIn(ViewModelComponent::class)
object WebServicesModule {
@Provides
@Default
fun provideDefault(factory: MyAssistedFactory) = factory.create()
}
@AssistedFactory
interface MyAssistedFactory {
fun create(sharedPreferencesName: String ?= null): SharedPreferencesHelper
} **Also, note that the fix for #2370 is not yet included in a release. It should be out with the next Dagger release, 2.33. |
@bcorso Thanks Is my case is an unusual scenario? This is a little bit strange for me there is not a simple solution |
@alizarei95 see the last part of my previous comment:
|
@bcorso what about last part of my previous question?
|
@bcorso Do you have any time estimation for releasing 2.33? |
You can use Square's AssistedInject for assisting inject at this time. And when 2.33 is out you change just annotations (May need to remove some lines) |
@beigirad we're should have a release out within the next week or two |
Closing this as a dupe of #2370 |
I am using Hilt (v2.32-alpha) dependency injection with viewmodel. I have a class with 2 parameters, the first is context and the second is an optional string so if not provide any value this takes null. To achieve this in Hilt I read below doc: https://dagger.dev/dev-guide/assisted-injection.html
This is my code :
And Hilt Module :
AssistedFactory interface:
And my viewmodel :
But build fails with this error:
Dagger does not support providing @AssistedInject types.
The text was updated successfully, but these errors were encountered: