koinContext has not been initialized

Created on 18 Nov 2017  路  4Comments  路  Source: InsertKoinIO/koin

Implemented everything similar to the wiki and got this error:

                                                                             java.lang.RuntimeException: Unable to start activity ComponentInfo{com.youtube.tedho.kotlinyoutube/com.youtube.tedho.kotlinyoutube.MainActivity}: kotlin.UninitializedPropertyAccessException: lateinit property koinContext has not been initialized

Most helpful comment

Also check of you have the MailApplication.kt register in the Manifest

All 4 comments

seems you have not used any starter function.

Can you give us your code snippet?

Hi @TedHoryczun

As mentioned by @arnaudgiuliani some code snippet would really help to support you.
In the mean time you can double check the provided sample app here : Sample App

Have a look at the Koin modules definitions in the file all_modules.kt and more specifically this line in MainApplication.kt which seems to be what you are missing.

Also check of you have the MailApplication.kt register in the Manifest

In my case the "lateinit property koinContext has not been initialized" exception error happened because of missing android:name=".KoinApp" in the manifest in the The KoinApp extends Application().
It makes sense:

_"The fully qualified name of an Application subclass implemented for the application. When the application process is started, this class is instantiated before any of the application's components."_

https://developer.android.com/guide/topics/manifest/application-element#nm

The question is how to properly try/catch this so the error is better described.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hkelidari picture hkelidari  路  3Comments

luna-vulpo picture luna-vulpo  路  4Comments

leodeleon22 picture leodeleon22  路  4Comments

erikhuizinga picture erikhuizinga  路  3Comments

fmobus picture fmobus  路  4Comments