question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Random NoBeanDefFoundException

See original GitHub issue

Describe the bug Some NoBeanDefFoundException are triggered “randomly”.

It usually works OK, but sometimes it fails.

Example of stacktrace:

Caused by org.koin.core.error.NoBeanDefFoundException: No definition found for class:'com.jeff.feature.turndetail.presentation.detail.TurnDetailRenderer'. Check your definitions!
       at org.koin.core.scope.Scope.throwDefinitionNotFound(Scope.kt:246)
       at org.koin.core.scope.Scope.resolveInstance(Scope.kt:216)
       at org.koin.core.scope.Scope.get(Scope.kt:181)
       at com.jeff.feature.turndetail.presentation.detail.TurnDetailFragment$$special$$inlined$inject$1.invoke(Scope.kt:396)
       at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:81)
       at com.jeff.feature.turndetail.presentation.detail.TurnDetailFragment.getRenderer(:2)
       at com.jeff.feature.turndetail.presentation.detail.TurnDetailFragment.access$getRenderer$p(TurnDetailFragment.kt:34)
       at com.jeff.feature.turndetail.presentation.detail.TurnDetailFragment$turnResId$2.invoke(TurnDetailFragment.kt:75)
       at com.jeff.feature.turndetail.presentation.detail.TurnDetailFragment$turnResId$2.invoke(TurnDetailFragment.kt:34)
       at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
       at com.jeff.feature.turndetail.presentation.detail.TurnDetailFragment.getTurnResId(:2)
       at com.jeff.feature.turndetail.presentation.detail.TurnDetailFragment.setupUI(TurnDetailFragment.kt:103)
       at com.jeff.library.base.presentation.fragment.StatelessJeffViewModelExtFragment.onViewCreated(StatelessJeffViewModelExtFragment.kt:50)
       at com.jeff.library.base.presentation.fragment.JeffViewModelExtFragment.onViewCreated(JeffViewModelExtFragment.kt:19)
       at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:2974)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:550)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:277)
       at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:112)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1636)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3112)
       at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:3056)
       at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:251)
       at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:473)
       at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1433)
       at android.app.Activity.performStart(Activity.java:7986)
       at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3677)
       at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
       at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:237)
       at android.app.ActivityThread.main(ActivityThread.java:8167)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

To Reproduce I have not been able to reproduce the error. I just see the crashes tracked on Crashlytics.

Expected behavior Provide the class all times if it is possible.

Koin project used and used version (please complete the following information): org.koin:koin-core:2.1.6 org.koin:koin-core-ext:2.1.6 org.koin:koin-androidx-fragment:2.1.6 org.koin:koin-androidx-scope:2.1.6 org.koin:koin-androidx-viewmodel:2.1.6

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:13

github_iconTop GitHub Comments

2reactions
valeriyocommented, Jan 14, 2021

This just happened to me as well, also with Koin 2.1.6

The crash occurred only once on Android 6.0.1 (Galaxy J3 Emerge) - and from the log before the crash, I can tell that the same resolution previously worked. So, it looks like it randomly failed. The crash occurred on main thread.

1reaction
valeriyocommented, Mar 7, 2021

This happens when the app is restoring its saved state - from android.app.ActivityThread.main at the top of callstack, and by that time the Scope instance (where org.koin.core.scope.Scope.resolveInstance fails) has been created already.

Does Koin do anything asynchronously?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Koin: NoBeanDefFoundException, Check your module ...
I had the same problem, but in my case Koin was unable to resolve an implementation of interface. I had: interface MessagesRepository {....
Read more >
Koin Context Isolation: setup correctly and avoid random ...
Coding example for the question Koin Context Isolation: setup correctly and avoid random NoBeanDefFoundException-kotlin.
Read more >
Caused by org koin core error NoBeanDefFoundException No def ...
Caused by org koin core error NoBeanDefFoundException No definition found for class com emirhan controller UserDataSourceImp Check your definitions single ...
Read more >
Android – Koin: NoBeanDefFoundException, Check your ...
This works reliably, because it is based on the information about running services provided by the Android operating system through ActivityManager# ...
Read more >
android - Koin. Cannot inject to fragment with ScopeActivity - Stack ...
NoBeanDefFoundException: No definition found for class:'com.example.app. ... Context Isolation: setup correctly and avoid random NoBeanDefFoundException ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found