Dependency Injection With Koin |

In this tutorial, you’ll get to know Koin, one of the most popular new frameworks for dependency injection.

This is a companion discussion topic for the original entry at
1 Like

Thanks for the tutorial. : )
But, a lot of build errors when i follow along the tutorial, I need to keep compare the final Project to solve the errors… :neutral_face:

eg. missing < Student > in many places.
missing KoinComponent in AppRepository class

1 Like

@pablo Can you please help with this when you get a chance? Thank you - much appreciated! :]

1 Like

Hi @yuan25, thanks for you comments!

Sorry about the inconveniences following the tutorial. It seems the code snippets have been wrongly altered during the post-production process. I have gone through the article again checking everything you’ve pointed out.

Feel free to try it again and don’t hesitate posting any other comment. Thanks!

Awesome! Really looking forward to use Koin.

1 Like

@softaai Glad you like it! :]

Thanks for very useful tutorial!
There is one moment missed in text, injecting sharedPreferences in finish part

1 Like

@pablo Do you have any feedback about this? Thank you - much appreciated! :]

Koin is a service locator pattern, not a true DI. As such, you get no compile-time safety or runtime guarantees when your scopes aren’t properly wired up. And then your app could easily crash in production because of Koin. Dagger, on the other hand, provides 100% compile-time safety and dependency graph generation up-front, and you can be certain that no runtime crash would occur because of Dagger.

1 Like

Hi @igorganapolsky, thanks for your comments!

You are absolutely right, Koin is not a true DI, although it is used to inject/offer dependencies into classes. It is said in the article that Dagger 2 is the defacto solution nowadays. The goal of the piece of writing was to offer developers a valid alternative to decouple their Android applications, avoiding the (IMHO) learning curve Dagger 2 possesses.

I have personally used Dagger 2 quite a lot for large projects, and I have eventually found myself a bit lost, for example in multi-module applications. Koin, on the other hand, is natively written in Kotlin, and has perfectly fit my needs in a quick, neat and straightforward way.


Hi @dima_def, thanks for your comments!

Sorry about this late response, I missed this message. Could you please be more specific pointing out when you got lost? It would be rather valuable for other readers and a good way of improving my writings!


This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!