DaggerAppCompatActivity with support fragments only
See original GitHub issueI’m extending DaggerAppCompatActivity
, but the compilation fails, because I only have support library fragments, and the multibind map for android.app.Fragment
s isn’t generated (I guess).
The error is the following:
Error:(18, 8) error: [dagger.android.AndroidInjector.inject(T)] java.util.Map<java.lang.Class<? extends android.app.Fragment>,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends android.app.Fragment>>> cannot be provided without an @Provides-annotated method.
java.util.Map<java.lang.Class<? extends android.app.Fragment>,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends android.app.Fragment>>> is injected at
dagger.android.DispatchingAndroidInjector.<init>(injectorFactories)
dagger.android.DispatchingAndroidInjector<android.app.Fragment> is injected at
dagger.android.support.DaggerAppCompatActivity.frameworkFragmentInjector
???.MainActivity is injected at
dagger.android.AndroidInjector.inject(arg0)
I can create my own base class that doesn’t implement HasDispatchingFragmentInjector
, but I would like to keep using the library provided classes. What could be a workaround for this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Dagger2 with Androidx, SupportFragmentInjector issue
I am trying to implement Dagger2 injection in a new app and the only thing that fails is DaggerAppCompatActivity and SupportFragmentInjector.
Read more >How to use Android Injector for Activity and Fragment objects ...
I started to add AndroidInjectionModule as a module in the component. This module should be installed in the component that is used to...
Read more >Package dagger.android.support
An AppCompatActivity that injects its members in DaggerAppCompatActivity.onCreate(Bundle) and can be used to inject Fragment s attached to it.
Read more >Getting started with Dagger 2.27 on Android by example
It just consists of an Activity with a Fragment and a ViewModel ... to inject Fragments, we've to include dagger-android-support and the ...
Read more >Injecting Activities with Dagger2 and ... - YouTube
You must extend the activities marked with the @ContributesAndroidInjector by the DaggerAppCompatActivity class. ➤ Watch the dagger course ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just realized I missed
AndroidInjectionModule
from my component, declaring the multibinds is exactly its purpose.I see. In this case, it might be worth removing the mentioning.