Hello everyone! I want to create library, but alre...
# dagger
s
Hello everyone! I want to create library, but already using Hilt in lib classes. Q: How to create library that doesn't need Hilt/Dagger from other developers? Hilt needs Application class and that is the main problem.
a
I don't think that Hilt supports being used inside an SDK or library, as you've mentioned the main problem is that you don't have access to the host app's Application class that has to be setup for Hilt. So I guess the only solution is to use vanilla Dagger and make it as an implementation details of your library
s
Thanks, @Ahmed Ibrahim! I also thought about such a solution, but I wanted to simplify the task.
a
If your library will have many Fragments/Activities, there's also the possibility of using dagger-android without an Application class, but that requires a deep understanding on how Dagger-Android works, and don't advice that route unless you know what you're doing.