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:
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.
Jovan
08/25/2020, 12:21 PM
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
Archie
08/25/2020, 12:22 PM
In this case, I am not trying to provide
SomeInterfaceFromALibrary
or any object within the library to the dependency graph.
j
Jovan
08/25/2020, 12:23 PM
Hmm are you using retrofit?
a
Archie
08/25/2020, 12:24 PM
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.
Archie
08/25/2020, 12:28 PM
@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
Jovan
08/25/2020, 12:30 PM
Not sure mate. I guess there is some public property that has connection with that library. Sorry nothing else comes on my mind.