我在使用 Retrofit 2 beta 2 时遇到了下一个问题:
java.lang.IllegalArgumentException: API interfaces must not extend other interfaces.
这是因为我有一个 Retrofit API 接口,如下所示:
public interface RetrofitBaseAPI {
@POST
Call<LoginResp> login(@Url String url, @Body LoginReq loginReq);
@POST
Call<String> logout(@Url String url, @Header("Cookie") String sid);
}
例如,其中之一是这样的:
public interface RetrofitWiserLinkAPI extends RetrofitBaseAPI {
@GET("/rs/DeviceIdentification")
Call<DeviceId> getDeviceIdentification(@Header("Cookie") String sid);
}
然后,我还有其他三个接口,这三个接口都是从这个 RetrofitBaseAPI 接口扩展而来的。
当我尝试使用给定接口调用 Retrofit.create(Class class) 时,我总是收到此错误。
据我所读,唯一的解决方案是创建三个独立的接口。这是真的吗?有人知道另一种解决方案吗?
我觉得有点奇怪,我们需要重复代码,但是,也许有一个我不明白的原因......
提前致谢!
Thanks,
编辑:使用最终的 Retrofit 2 发行版本时出现同样的问题。我猜这是Retrofit的限制......