I have created a brand new Android application and...
# kodein
j
I have created a brand new Android application and am trying to add Kodein, but the moment I add it an Activity, I get a weird (and unhelpful) exception when building. My activity:
Copy code
class MainActivity() : AppCompatActivity(), DIAware {
    override val di by di()
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

    }
}
My application:
Copy code
class PromptsApplication: Application(), DIAware  {
    override val di by DI.lazy { }
}
The exception:
r
What is the import for the ‘di()’ function in your activity ?
j
The Kodein imports look like this:
Copy code
import org.kodein.di.DI
import org.kodein.di.DIAware
r
you don’t have any
import org.kodein.di.android.di
?
by di()
is part of a specific gradle module.
j
Thanks, that was the issue! Not sure why auto complete didn’t work correctly, but I will keep an eye on it in the future.
r
to avoid this you can use
closestDI()
function, it’s the same, it just prevents from this issue.
👍 1