Dagger hilt 2.42
I am trying to provide this class using lazy dagger injection.
class AlgoliaAnalyticsProvider @Inject constructor(
private val clientInsights: Lazy<ClientInsights>,
private val coroutineDispatcherProvider: CoroutineDispatcherProvider
)
In my AppModule I have the following:
@Singleton
@Provides
fun provideClientInsights(remoteConfigProvider: RemoteConfigProvider): Lazy<ClientInsights> {
return lazy { ClientInsights(
ApplicationID(BuildConfig.ALGOLIA_APP_ID),
APIKey(remoteConfigProvider.keyAlgoliaApiKey)
)}
}
I also have this where I pass the AlgoliaAnalyticsProvider
@Singleton
@Provides
fun provideAnalyticsProvider(
firebaseAnalyticsProvider: FirebaseAnalyticsProvider,
crashlyticsUserPropertiesProvider: CrashlyticsUserPropertiesProvider,
caMPAnalyticsProvider: CaMPAnalyticsProvider,
algoliaAnalyticsProvider: AlgoliaAnalyticsProvider
) = AnalyticsProvider(
listOf(
firebaseAnalyticsProvider,
crashlyticsUserPropertiesProvider,
algoliaAnalyticsProvider
)
)
I keep getting this error:
error: [Dagger/MissingBinding] kotlin.Lazy<? extends com.algolia.search.client.ClientInsights> cannot be provided without an @Provides-annotated method.
public abstract static class SingletonC implements CDSApplication_GeneratedInjector,
^
kotlin.Lazy<? extends com.algolia.search.client.ClientInsights> is injected at
com.centraldepartment.app.analytics.provider.AlgoliaAnalyticsProvider(clientInsights, …)
com.centraldepartment.app.analytics.provider.AlgoliaAnalyticsProvider is injected at
com.centraldepartment.app.analytics.AnalyticsModule.provideAnalyticsProvider(…, algoliaAnalyticsProvider, …)
But if I comment out the code below it seems to work:
@Singleton
@Provides
fun provideAnalyticsProvider(
firebaseAnalyticsProvider: FirebaseAnalyticsProvider,
crashlyticsUserPropertiesProvider: CrashlyticsUserPropertiesProvider,
caMPAnalyticsProvider: CaMPAnalyticsProvider,
// algoliaAnalyticsProvider: AlgoliaAnalyticsProvider
) = AnalyticsProvider(
listOf(
firebaseAnalyticsProvider,
crashlyticsUserPropertiesProvider,
// algoliaAnalyticsProvider
)
)