2

I want to develop an android library that contains no UI/ViewModel. It will have the business logic only. There will be another application that would use this library application. As per this documentation

All apps that use Hilt must contain an Application class that is annotated with @HiltAndroidApp.

Also, Hilt currently supports the following Android classes:

 - Application (by using @HiltAndroidApp) 
 - Activity 
 - Fragment 
 - View 
 - Service
 - BroadcastReceiver

Below are the queries:

  1. Library will not have such classes that contain the Application class. In this case, how to use Hilt with the Library(Without making any dependency on an application that will use this library)?

  2. Library will not have any UI/ViewModel and will have the core logic only. In this case, Can Hilt be used for dependency injection? If yes, how to inject the same?

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Hey You
  • 303
  • 3
  • 16
  • 1
    Does this answer your question? [Hilt using in android library](https://stackoverflow.com/questions/63246625/hilt-using-in-android-library) – ADM Oct 19 '20 at 04:16
  • 1
    About your other question . KOIN is basically a Service locator not a DI while Dagger is a DI there is a thin line between them. Read about their comparison to make a choice . – ADM Oct 19 '20 at 04:18
  • @ADM I don't want to give any responsibilities to the actual application and want to use the Hilt independently within the library application. With reference of given post, this point is still not clear if one can use the Hilt within the Library (without any dependency on application which is using that library) – Hey You Oct 19 '20 at 08:39

0 Answers0