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.

Dagger-android application build failed

See original GitHub issue

I made a sample application and did all steps from the manual. But something is not working.

Error:(11, 8) error: [dagger.android.AndroidInjector.inject(T)] java.util.Map<java.lang.Class<? extends android.support.v4.app.Fragment>,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends android.support.v4.app.Fragment>>> cannot be provided without an @Provides-annotated method.
java.util.Map<java.lang.Class<? extends android.support.v4.app.Fragment>,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends android.support.v4.app.Fragment>>> is injected at
dagger.android.DispatchingAndroidInjector.<init>(injectorFactories)
dagger.android.DispatchingAndroidInjector<android.support.v4.app.Fragment> is injected at
dagger.android.support.DaggerApplication.supportFragmentInjector
com.*.*.presentation.component.Application is injected at
dagger.android.AndroidInjector.inject(arg0)

My activity inherits DaggerAppCompatActivity, and my application is here:

public class Application
        extends DaggerApplication {
    @Inject
    DispatchingAndroidInjector<Application> injector;

    @Override
    public void onCreate() {
        super.onCreate();
        DaggerApplicationComponent.create()
                                  .inject(this);
    }

    @Override
    protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
        return injector;
    }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10

github_iconTop GitHub Comments

130reactions
ronshapirocommented, Jun 21, 2017

You need to include AndroidSupportInjectionModule. That protects you in case you ever add a support fragment in the future.

On Wed, Jun 21, 2017, 8:29 AM Artem Shalaev notifications@github.com wrote:

@JonathanMerritt https://github.com/jonathanmerritt Thats what I do. I extend Support Dagger Application class. And I have no any fragments. So I can’t understand why I get this error.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/dagger/issues/783#issuecomment-310063405, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwY3Q36JYrs_u1dlv_EJ7YKV1ZGATiWks5sGQyagaJpZM4OA2Tq .

35reactions
randallmitchellcommented, Dec 31, 2017

I don’t think this ticket should be closed. The additional module is not documented. It seems like it should not be required either. Maybe the docs should be updated here or the requirement should be removed.

I ran into this problem some time after getting the basic sample with empty modules working. It happened while trying to provide additional dependencies from my Activity module. So the AndroidSupportInjectionModule is not required, then it is required later at a seemingly arbitrary point.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dagger build error - java - Stack Overflow
with newest android studio (3.1.1) and gradle (3.1.1) on mac osx. Of course I've tried invalidating cache and restarts, cleans etc. I've ...
Read more >
Build errors: kapt3 dagger graph failure - Issue Tracker
With the recent canary, kapt fails to build my project. I'll attach it. ... e: C:\Users\daykm\StudioProjects\P5Executioner\app\build\tmp\kapt3\stubs\appDebug\com\ ...
Read more >
Using Dagger in Android apps
To use Dagger in your project, add these dependencies to your application in your build.gradle file. You can find the latest version of...
Read more >
"Build failed" error pointing to DI:dagger while building-kotlin
[Solved]-Android: "Build failed" error pointing to DI:dagger while building-kotlin · Related Query · More Query from same tag · Contact Us · Quick...
Read more >
Issues faced when setup Dagger 2 on Kotlin | by Elye - Medium
Upon first compilation, you'll see this error keep occuring. Don't know why it happens. Apparently, you just need to delete and clean your...
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