question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DaggerAppCompatActivity with support fragments only

See original GitHub issue

I’m extending DaggerAppCompatActivity, but the compilation fails, because I only have support library fragments, and the multibind map for android.app.Fragments 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:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
sebokmartoncommented, Mar 25, 2017

I just realized I missed AndroidInjectionModule from my component, declaring the multibinds is exactly its purpose.

0reactions
sebokmartoncommented, Mar 25, 2017

I see. In this case, it might be worth removing the mentioning.

Dagger also provides a [DaggerApplication] for the same purpose — all you need to do is to extend it and override the applicationInjector() method to return the component that should inject the Application.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found