I was trying to provide a common DataStore<Preferences> so that the same preference file could be used in multiple places but I got the helpful error message:
Cannot find symbol: DaggerMyApplication_HiltComponents_SingletonC.builder()
@Module
@InstallIn(ApplicationComponent::class)
object DataStoreModule {
@Provides
fun provideDataStore(@ApplicationContext context: Context): DataStore<Preferences> = context.createDataStore("settings")
}
I can however do the following and use it within an @Inject constructor.
@Singleton
class DataStoreProvider @Inject constructor(@ApplicationContext context: Context) {
val dataStore: DataStore<Preferences> = context.createDataStore("settings")
}
I assume that the extension createDataStore is doing something that Hilt does not like but I'd appreciate an explanation of what is going on even if the problem is not solvable.