androidkotlindagger-hiltclean-architecturemodular

Application class annotated with @HiltAndroidApp has to be defined in an android application project


I am having an Application class already annotated with @HiltAndroidApp but it is in a different module than App module, i needed it to be in the framework module so i can access it from my Service class . what can be the issue here knowing i have all the Hilt dependencies added to the Framework module gradle .


Solution

  • i ended up using this in my App module

    @HiltAndroidApp
    class MyApp : FrameWorkApp()
    

    and this in the framework module

    open class FrameWorkApp  : Application() {
    }
    

    and in my appModule

        @Provides
        @Singleton
        fun provideFollowMe(@ApplicationContext app: Context): FrameWorkApp  
    = app as FrameWorkApp