Home > Mobile >  KoinApplication has not been started on another activity
KoinApplication has not been started on another activity

Time:02-13

My app has a splash activity where i check for login and start Koin.

The problem is, when i go to another activity, put my app on recents (so android basicaly kills it) and go back, android try to open the activity again but Koin is not started so it crashes.

Am i doing something wrong or should i try to start Koin on every activity that uses it?

Here is how i'm starting Koin:

    onCreate......
    KoinApplication koin = KoinAndroidApplication.create(SplashActivity.this)
                .printLogger(Level.ERROR)
                .modules(
                        NetworkModule.getNetworkModule(),
                        MainModule.getMainModule()
                );
    startKoin(koin);

CodePudding user response:

Am i doing something wrong or should i try to start Koin on every activity that uses it?

You should start koin in your app's Application class like mentioned in the documentation - the Application will be created before any activity or other component is launched.

  • Related