I am having a hard time with understanding how Hilt builds the dependency graph with the usage of EntryPoints. I have managed to use @HiltAndroidApp annotation within my Application class. My main AppComponent looks like that now:
@InstallIn(SingletonComponent::class)
@Module(
includes = [
ModuleX::class,
ModuleZ::class, ]
interface AggregatorModuleApplication
@InstallIn(SingletonComponent::class)
@EntryPoint
interface AppComponent {
fun mainActivityComponent() : MainActivityComponent
fun inject(application: AppApplication)
fun serviceComponent(serviceModule: ServiceModule): ServiceComponent
... (other fun returning components) }
That worked with such App class:
@HiltAndroidApp
class AppApplication :
open val appComponent: AppComponent = EntryPointAccessors.fromApplication(this, AppComponent::class.java)
appcomonent.inject(this)
Now I would need @AndroidEntryPoint inside Activity I have. What I did is add annotation @AndroidEntryPoint to it and this is MainActivityComponent interface:
@InstallIn(ActivityComponent::class)
@Module(
includes = [
Module0::class,
Module1::class,
Module2::class,...]
@InstallIn(ActivityComponent::class)
@EntryPoint
interface MainActivityComponent {
fun inject(activity: MainActivity)
fun componentOne(): ComponentOne
fun componentTwo(): ComponentTwo }
Now inside My Activity I call:
private val mainActivityComponent =
EntryPointAccessors.fromActivity(this,MainActivityComponent::class.java)
Error: error: [Dagger/MissingBinding] com.projecthilt.di.MainActivityComponent cannot be provided without an @Provides-annotated method. public abstract static class SingletonC implements AppApplication_GeneratedInjector,
What is wrong here or how should I take care of -> fun componentOne(): ComponentOne If this is an
@Subcomponent
interface ComponentOne {
fun inject(fragment: FragmentX)
fun inject(fragment: FragmentZ)
fun inject(fragment: FragmentY)