It is normal that a dependency in one module needs...
# dagger
a
It is normal that a dependency in one module needs to also be added to the main module when using hilt? I have a class in a module which uses a library:
Copy code
@AndroidEntryPoint
class MyFragment: Fragment(), SomeInterfaceFromALibrary {
    @Inject
    lateinit var someClass: SomeClass
    
    ....
}
Now whenenver I build my project it says "could not access SomeInterfaceFromALibrary" The only way I fixed it was to add the same dependency in the main module:
Copy code
:app
...
dependencies {
    implementation "someLibrary:version"
}

:otherModule
...
dependencies {
    implementation "someLibrary:version"
}
Is this intended or am I doing something wrong?
j
For example if you have some method in x module which takes a parameter of type provided by a library your main module will have to know for that library otherwise it wan’t be able to compile that method.
Basically your main module has knowledge of that method from another module but it also has to know where is defined the type of the parameter of that specific method.
a
In this case, I am not trying to provide
SomeInterfaceFromALibrary
or any object within the library to the dependency graph.
j
Hmm are you using retrofit?
a
Also, even when I try to do something like this:
Copy code
@AndroidEntryPoint
class MyFragment: Fragment() {
    @Inject
    lateinit var someClass: SomeClass
    
    private val myObject: SomeInterfaceFromALibrary {
        ....
    }

    ....
}
I still get the same error.
@Jovan yes I am. And I understand I have to add retrofit in the main module for the reason you specify (and I do add it there). Everything is fine with Retrofit. But for this Specific Library, which I don't provide in the dependency graph, seems to be the issue. Come to think of it I expereinced this after adding in
AssistedInject
could this possible be related?
j
Not sure mate. I guess there is some public property that has connection with that library. Sorry nothing else comes on my mind.
a
Alright Thanks nonetheless!