Search code examples
androidfirebasedagger

Android Dagger and Firebase


I am using Dagger dependency injection. It normally works fine but when I am using it to inject a component into a class that extends FirebaseInstanceIdService it fails the build. Is there something special about FirebaseInstanceIdService that prevents me from injecting into it or is there something I need to do to get it to work. I am not trying to inject an instance of the FirebaseInstanceIdService anywhere, just inject a dependancy into it

AppComponent has

void inject (AbcFirebaseInstanceIdService abcFirebaseInstanceIdService);

And the AbcFirebaseInstanceIdService has

public void inject(ApplicationComponent appComponent) {
        appComponent.inject(this);
    }

Solution

  • com.google.dagger:dagger-compiler:2.0.2 
    

    does not seem to work with

    com.firebase:firebase-client-android:2.3.1. 
    

    Having seen MikeNs code worked with an older version of dagger, made me try and upgrade my dagger version to 2.6.1. The same code that would not compile before now compiles.