0

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?

INDRAJITH EKANAYAKE
  • 3,894
  • 11
  • 41
  • 63
yoonhok
  • 2,575
  • 2
  • 30
  • 58

1 Answers1

1

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

Bach Vu
  • 2,298
  • 1
  • 15
  • 19
  • Oh, good! then I have one more question. If I handle the exception using the RxJavaPlugins.setErrorHandler, then "my logic" that should run after subscribe will not be run, right? – yoonhok May 09 '19 at 08:00
  • Your subscriber throws an error, so originally, it does not run `my logic` already, it would trigger `Log.e(TAG, "error: ${t.message}", t)` if your subscriber is not disposed. – Bach Vu May 09 '19 at 08:02