You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use the multi binding, but i'm getting the following error:
error: [Dagger/MissingBinding] java.util.Map<java.lang.String,? extends com.snazhmudinov.todo.Storage> cannot be provided without an @Provides-annotated method.
Code snippets:
interface Storage {
fun get(): String
fun set(t: String)
}
@Singleton
class StringStorage @Inject constructor() : Storage {
override fun get(): String {
return ""
}
override fun set(t: String) {
}
}
@Singleton
class String2Storage @Inject constructor() : Storage {
override fun get(): String {
return ""
}
override fun set(t: String) {
}
}
@Singleton
class StorageProvider @Inject constructor(val storages: Map<String, Storage>)
Module declaration:
@Module
abstract class StorageModule {
@IntoMap
@Binds
@StringKey("StringStorage")
abstract fun bindStringStorage(storage: StringStorage): Storage
@IntoMap
@Binds
@StringKey("String2Storage")
abstract fun bindString2Storage(storage: String2Storage): Storage
}
I'm trying to use the multi binding, but i'm getting the following error:
error: [Dagger/MissingBinding] java.util.Map<java.lang.String,? extends com.snazhmudinov.todo.Storage> cannot be provided without an @Provides-annotated method.
Code snippets:
Module declaration:
Component:
And finally, the activity injection:
Kotlin version: 1.3.50
Dagger version: 2.24
AS version: 3.5
The text was updated successfully, but these errors were encountered: