相关文章推荐

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

Describe the bug
When injecting a ViewModel(with parameters) with KOIN, an Activity is being leaked through KoinFactory->ViewModel->Fragment->NavHostFragment->NavController->Activity.

To Reproduce

  • Setup project with the new androidx.Navigation library
  • Inject ViewModel with parameters to the Fragment
  • Close app
  • LeakCanary reports Activity leak for the activity hosting the NavHostFragment.
  • Expected behavior
    No memory leak.

    Koin project used and used version (please complete the following information):
    koin-core, -android, -android-architecture 0.9.3
    androidx.Navigation - 1.0.0-alpha02

    Additional context '
    LeakCanary report:
    https://gist.github.com/trobertsca/c56cb2a87be67b4ad1e54f5f54a44f4c

    I'm not 100% sure this is due to KOIN, but my google-fu is failing me.

    Here's a gist with what I believe are all the relevant files: https://gist.github.com/trobertsca/dd1acd78a0d3e9636893c4258933b1a5

    If you need anything more just let me know. (And excuse the code, I'm somewhat new to kotlin+android :) )

    @trobertsca could you help me save time, by making a real android project and share it as a public github project?
    It will help investigate ;)

    it's fixed. Just need time to release it. Available in koin-android-viewmodel version 1.0.0-alpha-28
    I'm releasing it

     
    推荐文章