Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KoinAppAlreadyStartedException after closing the app and relaunching it quickly #1864

Open
armond-avanes opened this issue May 1, 2024 · 0 comments

Comments

@armond-avanes
Copy link

Describe the bug
I'm using Koin in my Compose Multiplatform project and trying to keep as much as possible in commonMain, so I'm using KoinApplication(...) in my top layer composable function.

When I close the app (Android) and relaunch it quickly, I get KoinAppAlreadyStartedException. I believe that when I close the app, the activity is destroyed but the app itself is still alive for a couple of more seconds... in that case, when I relaunch it quickly, the app itself is not reinitiated (already exists) but the activity is recreated (because it has been destroyed). When KoinApplication(...) is called and it detects that the Koin has already been started in the past, it throws the exception.

I know I can make use of KoinContext() and instead start the Koin in "Application.onCreate()" to fix this issue. But then I will need to repeat a similar logic for iOS and Desktop which is what I'm trying to avoid.

To Reproduce
Steps to reproduce the behavior:

  1. Close the app
  2. Quickly relaunch it
  3. See error

Expected behavior
KoinApplication should handle this situation gracefully.

Koin module and version:

  • koin-core:3.6.0-Beta2
  • koin-compose:1.2.0-Beta2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant