Multibinding for Dagger 2.9 (Sets and Maps)

If you didn’t use multibinding before, you can see how it worked earlier until 2.8 there:

In the Dagger version 2.8 Provides.Type deprecated. It means, since version 2.9 Multibinding using type doesn’t work:

@Provides(type = Provides.Type.SET) - now deprecated

Now instead type you can use annotations in your module.

@IntoSet for Set:

Modified example from https://medium.com/@hamidgh/dagger-multibinding-sets-and-maps-713254b7f734

@IntoMap for Map:

Modified example for Map

Instead of @StringKey you can use @IntKey, @LongKey, @ClassKey

On activity, fragment, etc.. you can inject as previously:

Set:

@Inject
Set<Translator> mTranslatorSet;

Map:

@Inject
Map<Strig, Translator> mTranslatorMap;