StandAloneContext Koin 实例为空
StandAloneContext Koin instance is null
当我将 Koin 添加到项目中时,我将 运行 保存到以下错误中。 StandAloneContext Koin instance is null
implementation 'org.koin:koin-android:1.0.2'
Modules.kt
val UIModule: Module = module {
factory<MainContract.Presenter> { MainPresenter() }
}
val appModules = listOf(UIModule)
App.kt
class App : Application() {
private val TAG : String = Application::class.java.name
override fun onCreate() {
super.onCreate()
startKoin(this, appModules)
}
}
我花了整整一个下午试图解决这个问题,并且没有完全放弃 Koin,我又检查了我的应用程序 class 一次,最后注意到来自 Android工作室过来App
class.....
结果我只需要将应用程序 class 添加到清单中... ♀️♀️♀️
AndroidManifest.xml
<application android:name=".app.App" ... />
如果这甚至可以帮助 1 个人不浪费整整 4 个小时,那么值得我在此处发布此 question/answer。
干杯!
当我将 Koin 添加到项目中时,我将 运行 保存到以下错误中。 StandAloneContext Koin instance is null
implementation 'org.koin:koin-android:1.0.2'
Modules.kt
val UIModule: Module = module {
factory<MainContract.Presenter> { MainPresenter() }
}
val appModules = listOf(UIModule)
App.kt
class App : Application() {
private val TAG : String = Application::class.java.name
override fun onCreate() {
super.onCreate()
startKoin(this, appModules)
}
}
我花了整整一个下午试图解决这个问题,并且没有完全放弃 Koin,我又检查了我的应用程序 class 一次,最后注意到来自 Android工作室过来App
class.....
结果我只需要将应用程序 class 添加到清单中... ♀️♀️♀️
AndroidManifest.xml
<application android:name=".app.App" ... />
如果这甚至可以帮助 1 个人不浪费整整 4 个小时,那么值得我在此处发布此 question/answer。
干杯!