异常记录:java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread

异常描述

  • 有两处报错
 Caused by: java.lang.NoSuchMethodError:No virtual method isSuccess()Z in class Lretrofit2/Response;

 java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread
  • 使用环境
    1. 使用Retorfit结合Rxjava实现网络请求
    2. 在retrofit中添加拦截器

原因分析

基于okhttp3的拦截器版本与retrofit使用的版本不一致

解决方法

这是我改正后的依赖配置
retrofit最新版本是2.4.0,基于okhttp3的3.11.0版本,所以把 拦截器的版本修正为3.11.0

    //retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'io.reactivex:rxandroid:1.1.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.4.0'
    implementation 'com.trello.rxlifecycle2:rxlifecycle:2.2.1'
    implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.1'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'

* 注意:在使用retrofit过程中无需另外添加okhtt3的依赖,本身已实现okhttp3的支持*

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值