Sign in Go Pro

Dependency Injection in Android using Kodein

Scoped Injection: Activity Scope

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next



On previous lessons we added an Application Kodein instance to bring application dependencies like singletons into scope. On this one, you will learn about:
* The ideal amount of scopes to have in any app.
* The relation of inheritance between scopes.
* How to add an Activity Scope.
* How to extend the Application scope in the Activity one.
* How to open the door for specific Activity Bindings per Activity.




Hello, I'm trying to use the "by retainedKodein" but it's missing, I'm using these dependencies implementation "org.kodein.di:kodein-di-generic-jvm:$kodeinVersion", implementation "org.kodein.di:kodein-di-framework-android-x:$kodeinVersion" where kodeinVersion is 5.2.0. I also had to add this maven { url "" } to the root build.gradle file. The retainedKodein is a nice convenience, it would be nice to be able to use. Thanks!

Hey, please take a look at the sample repo, it was updated to support version 5.2.0 which has some syntax upgrades. The problem might be in how you're referencing it.

Hopefully it helps! Thanks for watching the course.

My bad, I didn't realise this was an extension function on the Activity object, I was trying to access this from a fragment. Works now, thank you!

You need to go PRO to post comments.

Lessons in Dependency Injection in Android using Kodein