【发布时间】:2019-07-22 13:41:59
【问题描述】:
我一直在使用 workManager,它在 dagger2 上运行良好,但是当我使用 WorkContinuation.combine() 进行链接时,WorkerFactory 出现了问题
我的工人没有初始化
崩溃报告是
java.lang.IllegalArgumentException: unknown worker class name: androidx.work.impl.workers.CombineContinuationsWorker
at incubasys.aydo.repositories.worker.WorkerFactory.createWorker(WorkerFactory.kt:22)
at androidx.work.WorkerFactory.createWorkerWithDefaultFallback(WorkerFactory.java:81)
at androidx.work.impl.WorkerWrapper.runWorker(WorkerWrapper.java:228)
at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:127)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
发生崩溃的WorkerFactory
class DaggerWorkerFactory @Inject constructor(
private val workerFactories: Map<Class<out ListenableWorker>, @JvmSuppressWildcards Provider<ChildWorkerFactory>>
) : WorkerFactory() {
override fun createWorker(
appContext: Context,
workerClassName: String,
workerParameters: WorkerParameters
): ListenableWorker? {
val foundEntry =
workerFactories.entries.find { Class.forName(workerClassName).isAssignableFrom(it.key) }
//crashes here
val factoryProvider = foundEntry?.value
?: throw IllegalArgumentException("unknown worker class name: $workerClassName")
return factoryProvider.get().create(appContext, workerParameters)
}
}
只有在我使用 WorkContinuation.combine() 时才会崩溃。
【问题讨论】:
-
你能贴出你用来打电话给
WorkContinuation.combine()的代码吗?
标签: android kotlin dagger-2 android-architecture-components android-workmanager