-
-
Notifications
You must be signed in to change notification settings - Fork 719
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
NoBeanDefFoundException in WorkManager #1729
Comments
Hi, I have the same issue. Is there any solution or workaround for this? |
We ended up removing the class MyWorker(
appContext: Context,
params: WorkerParameters,
) : Worker(appContext, params),
KoinComponent {
// Use `by inject()` to get a lazy dependency.
private val myDependency: SomeClass by inject()
override suspend fun doWork(): Result {
// Only access the dependency in `doWork()`
myDependency.doSomething()
TODO("Return a result")
}
} This makes the class more difficult to test but at least the crashes went away. I guess that this approach gives Koin a little more time to get the dependency graph ready. |
Can you check how I setup it in NowInAndroid, and compare with yours? https://github.com/InsertKoinIO/nowinandroid |
That is a big project to quickly check for the setup! 😄 Are you talking about the way you manually trigger the SyncWorker in the app's Application right here? I am afraid that we have too much code relying on having Koin initialized via the AndroidX Startup library to quickly make this change. I should really put together a demo project to help figure out the cause of this crash rather than try to find a workaround. |
Seems that worker is not well defined. But it needs deeper investigation on your side 🤔 |
Even in small workers and apps, this issue can happen:
Stack trace:
Questions to look into:
|
Describe the bug
We get occasional crashes when using
koin-androidx-workmanager
to inject our worker classes. It seems like this is a continuation of #1623.To Reproduce
Our flow is as follows:
Both the periodic and the one time workers produce NoBeanDefFoundEception crashes. It only happens to a small percentage of users, but it still happens with every release we make.
Koin module and version:
The text was updated successfully, but these errors were encountered: