Android Room RxJava UndeliverableException

时间:2019-05-09 02:42:07

标签: android rx-java android-room

我正在尝试修复我发布给游戏商店的应用中crashlytics报告的一些错误

我检查了日志,但不知道如何解决...

io.reactivex.exceptions.UndeliverableException: 
  at io.reactivex.plugins.RxJavaPlugins.onError (RxJavaPlugins.java:367)
  at io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual (SingleFromCallable.java:50)
  at io.reactivex.Single.subscribe (Single.java:3603)
  at io.reactivex.internal.operators.maybe.MaybeFilterSingle.subscribeActual (MaybeFilterSingle.java:40)
  at io.reactivex.Maybe.subscribe (Maybe.java:4290)
  at io.reactivex.internal.operators.maybe.MaybeSubscribeOn$SubscribeTask.run (MaybeSubscribeOn.java:54)
  at io.reactivex.Scheduler$DisposeTask.run (Scheduler.java:578)
  at io.reactivex.internal.schedulers.ScheduledRunnable.run (ScheduledRunnable.java:66)
  at io.reactivex.internal.schedulers.ScheduledRunnable.call (ScheduledRunnable.java:57)
  at java.util.concurrent.FutureTask.run (FutureTask.java:237)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:272)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
  at java.lang.Thread.run (Thread.java:762)
Caused by: android.arch.b.b.b: 
  at com.eastriver.workingtimer.data.source.WorkDao_Impl$4.call (WorkDao_Impl.java:172)
  at com.eastriver.workingtimer.data.source.WorkDao_Impl$4.call (WorkDao_Impl.java:129)
  at io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual (SingleFromCallable.java:44)
  at io.reactivex.Single.subscribe (Single.java:3603)

实际上,我所有的rx代码都在处理这样的错误:

class MyIntentService(
        private val disposable: CompositeDisposable = CompositeDisposable()
) : IntentService("MyIntentService") {

    ...

    override fun onHandleIntent(intent: Intent?) {
        disposable.add(
            workDao.getWorkById(getToday())
                .subscribeOn(Schedulers.io())
                .subscribe({
                    // my logic
                }, { t ->
                    Log.e(TAG, "error: ${t.message}", t)
                })
        )
    }

    override fun onDestroy() {
        super.onDestroy()
        disposable.clear()
    }
}

WorkDao是:

@Dao
interface WorkDao {
    @Query("SELECT * FROM work WHERE id = :id")
    fun getWorkById(id: Long): Single<Work>
}

但是我在崩溃报告中找不到错误日志。

我该怎么办?

1 个答案:

答案 0 :(得分:1)

好的,在我看来,onDestroy是在完成workDao.getWorkById(getToday())之前被调用的。因此,当您的订户已经处置时,它将引发错误。您现在可以尝试通过以下链接https://stackoverflow.com/a/49387916/2164363

处理来自RxJava本身的错误。

欢呼