skip to Main Content

I’m creating an android app and i have multiple repositories, each used in certain usecases classes. In my AppModule.kt file i provide all these constructors however i seem to have gotten errors about duplicate bindings and i’m not sure how to fix these. My code looks like this. `

    @Provides
    fun provideUseCases
  
}

The error i receive looks like enter code here

2

Answers


  1. Chosen as BEST ANSWER

    I fixed it by skipping all the specific collections and just inserting Firebase.firestore and differentiation in the repositories themselves


  2. Well, basically hilt has no way to difference between all of the functions that provide the same type, so:

        @Provides
        fun provideManagerRef() = Firebase.firestore.collection("manager")
    
        @Provides
        fun provideAdresesRef() = Firebase.firestore.collection("adres")
        @Provides
        fun providePandenRef() = Firebase.firestore.collection("panden")
        @Provides
        fun provideIssuesRef() = Firebase.firestore.collection("issues")
        @Provides
        fun provideKamersRef() = Firebase.firestore.collection("kamers")
    

    is impossible to differenciate for hilt when you try to inject a firebase collection somewhere, you can use the @Named annotation to avoid this error take a look at this for more info (step 5 and 6)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search