Handling Retrofit multiple dependent providers
See original GitHub issueI’not used to work with DI, but from theory point of view I decided to go to Toothpick for clarity and simplicity. However I got some issue resolving injection of Retrofit in my app.
I create a module “NetworkModule”
public class NetworkModule extends Module {
public NetworkModule(String urlPath) {
bind(Gson.class).toProvider(GsonProvider.class);
bind(Retrofit.class).toProviderInstance(new RetrofitProvider(urlPath, new GsonProvider().get()));
}
As you see some providers depends from others. RetrofitProvider need previously injected Gson dependency. How to deal with that ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Handle multiple retrofit client using dagger hilt as dependency ...
First, here I see you have provide 2 instances of retrofit. Put the @Named annotation for each instance of the retrofit you provide....
Read more >Modeling Retrofit Responses With Sealed Classes and ...
In this post, you will cover how to model Retrofit responses with Coroutines and Sealed classes to reduce code complexity and make your...
Read more >Manual dependency injection - Android Developers
Basics of manual dependency injection; Managing dependencies with a container; Managing dependencies in application flows; Conclusion.
Read more >Dagger 2 Android Example using Retrofit - GeeksforGeeks
Component: The connection between our dependency provider and dependency consumer is provided via an interface by annotating it with @Component.
Read more >Consuming APIs with Retrofit | CodePath Android Cliffnotes
In the past, Retrofit relied on the Gson library to serialize and deserialize JSON data. Retrofit 2 now supports many different parsers for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try adding a inject annotation to the constructor of the provider. Toothpick needs the inject annotation on the constructor to create factories.
Something like this:
@kelsos ok thank for the fix.