08/18/2022, 2:45 PM
Hi All, is it safe to use two DI frameworks (Koin & Hilt) at the same time in an Android project (temporarily)

K Merle

08/18/2022, 4:09 PM
Temporarily in many cases become forever. I wouldn't risk it.


08/18/2022, 4:44 PM
If you are migrating toward KMM, you will obviously have to use a multiplatform DI framework around the shared code, and over onto iOS. I think the reality of release schedules necessitates that Dagger in the Android UI code stay there for the time being. They co-exist but it causes confusion to know who manages what, which injection mechanism you should use in any given piece of code. I fall back to balancing “just because you can, doesnt mean you should” (have them coexist) and “if it aint broke, dont fix it.” (we have to release working code)

Landry Norris

08/18/2022, 9:39 PM
I feel like if there’s strong boundaries on where each is used, like with your example of dagger for UI and a multiplatform library for shared code, there’s less chance for confusion, but I’d definitely make sure that there’s a clear task to migrate completely on the roadmap. I’ve seen a number of temporary hacks to get a release out become a permanent part of the infrastructure.
I joined a project a couple years back, where there was a different backend for android and iOS, but both used the same database. To do anything, you’d need to make several calls (fooAndroid, fooAndroid2, fooAndroid3, etc.) and the server used the phone as a sort of ‘temporary memory’, since it would send back unrelated variables in the response, and the next call would need those variables as parameters. I’d imagine it started with someone not wanting to set up caching in their ‘stateless’ XML API because there was a release and ‘I’ll fix it later’.