Hello, do you have any tutorial on hilt in multi m...
# android
j
Hello, do you have any tutorial on hilt in multi module project? I want to iternalize my modules' usecases and implementations but when doing it straightforward hilt doesn't find dependencies
😶 2
b
Or something much more in depth than that?
j
Rather more in depth, this one I have already seen and still didn't understand
j
Is this what you're trying to accomplish?
MyUseCase
needs to be accessible to
app
module as its building the graph
Copy code
@Provides
fun providesMyUseCase(): MyUseUseCase {
   return MyUseCaseImpl() // MyUseCaseImpl is internal to module
}
convo might be more appropriate for #dagger
If you have app->moda->modb that means that app needs to include dependencies provided by the modules specified in modb otherwise will not be able to construct a single graph
j
Yes, that's exactly the behavior I wanted to achieve
And @Inject constructor won't give same result here because class won't be accessible in app? That's the reason for why it failed for me?
j
Correct
You'll have same issue if try to use
@Binds
j
Great thanks! Now I've got it 🙂
t
I am new to hilt/android app dev. How to provide/inject a class within a module when the class is internal?
j
Use an internal
@Provides
function or use an interface if it needs to be accessible to other modules
Copy code
@Provides
internal fun provideTheThing(): MyInternalClass {
  return MyInternalClass()
}