I am having the next problem using Retrofit 2 beta 2:
java.lang.IllegalArgumentException: API interfaces must not extend other interfaces.
This is because I have one interface for the API of Retrofit like this:
public interface RetrofitBaseAPI { @POST Call<LoginResp> login(@Url String url, @Body LoginReq loginReq); @POST Call<String> logout(@Url String url, @Header("Cookie") String sid); }
For example, one of them is this one:
public interface RetrofitWiserLinkAPI extends RetrofitBaseAPI { @GET("/rs/DeviceIdentification") Call<DeviceId> getDeviceIdentification(@Header("Cookie") String sid); }
And then, I have three other interfaces, the three of them extends from this RetrofitBaseAPI interface.
When I try to call the retrofit.create(Class class) with the given interface, I always receive this error.
As far as I was reading, the only solution is to create three independents interfaces. Is it true? Anybody knows another solution?
I find a little bit weird that we need to duplicate code, but well, maybe there is a reason I don't understand.....
Thanks in advance!
Thanks,
EDIT: Same problem using the final Retrofit 2 release version. I guess it is a limitation from Retrofit....
It's not possible to have a base Retrofit interface.
JakeWharton - the author of Retrofit:
Retrofit favors composition over inheritance. One interface per service.
So as you already found out, the only solution is to create three independents interfaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With