Retrofit---java.lang.NoSuchMethodError: No virtual method isSuccess()Z in class Lretrofit2/Response

来源:互联网 发布:网络骂人录音 编辑:程序博客网 时间:2024/05/18 05:12

项目中用了Retrofit+RxJava的架构,今天在项目运行中报了异常,报错日志如下

Caused by: java.lang.NoSuchMethodError: No virtual method isSuccess()Z in class Lretrofit2/Response; or its super classes (declaration of 'retrofit2.Response' appears in /data/data/com.hengda.smart.retrofitdemo/files/instant-run/dex/slice-retrofit-2.1.0_57685673f22b56e418e8e207266994b062f49604-classes.dex)

一 、 解决方案

1 目前最新的版本为如下、

compile 'com.squareup.retrofit2:retrofit:2.1.0'compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'

2 检查当前依赖的Retrofit版本

如果发现版本不一致,请更改进行升级,升级后,sync 同步一下,在进行编译,编辑成功。

二、发生原因

那么为什么会出现这个问题呢,先去GitHub上面探望一下retrofit的更新日志

这里写图片描述

从日志上看当前的2.1.0版本,response的判断名称进行了更改

当两个依赖版本不统一时,例如:

compile 'com.squareup.retrofit2:retrofit:2.1.0'compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'

这样的情况,版本不统一,方法找不到就会爆出该错误

这里写图片描述

4 0
原创粉丝点击