简体   繁体   中英

Android Room RxJava UndeliverableException

I'm trying to fix some error reported by crashlytics in my app which I released to play store

I checked the log, but I don't know how to fix it...

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)

Actually, all my rx code is handling the error like this:

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()
    }
}

And the WorkDao is:

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

But I cannot find my error log in the crash report.

What should I do?

Ok, it looks to me that onDestroy is called before workDao.getWorkById(getToday()) is done. So it throws error while your subscriber is already disposed. What you can try now is handling errors from RxJava itself by following this link https://stackoverflow.com/a/49387916/2164363

Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM