<https://docs.kodein.org/kodein-di/7.2/framework/a...
# kodein
m
https://docs.kodein.org/kodein-di/7.2/framework/android.html#_component_based_sub_di I am trying to use subDI to create activity scoped component
Copy code
override val di: DI by subDI(di()) {
Type mismatch. Required: DI Found: DIPropertyDelegateProvider<Any?>
r
you probably have a bad import on the
di()
function
m
oh, thanx, sorry I did not notice the reply. I have this one
org.kodein.di.android.x.ClosestKt#di(androidx.fragment.app.Fragment)
this one does not allow me to compile
org.kodein.di.android.ClosestKt#di()
r
The first one seems ok if you are using AndroidX as the extension function
Fragment.di()
extends
androidx.fragment.app.Fragment
I'm trying to reproduce your problem.
Did you try this import ?
m
then I would need to wrap it in a lambda right ?
image.png
r
Nope, you can just do the following
Copy code
class MainFragment : Fragment(), DIAware {

    override val di: DI by subDI(di()) {
        bind<String>("subDI-str") with singleton { "ABC" }
    }

    val str: String by instance("subDI-str")
}
the
di()
function return a delegate provider
m
ok, works now. so it seems I need this
Copy code
import org.kodein.di.android.subDI
instead of
Copy code
org.kodein.di.subDI
I think the
() -> org.kodein.di.DI
suggests its a lambda
bit If I select that
this import appears
Copy code
import org.kodein.di.android.subDI
and this function accepts
DIPropertyDelegateProvider<T>
you probably have a bad import on the 
di()
 function
so I have bad import on
subDI()
function
👍 1