-keepattributes Signature -dontwarn retrofit2.Platform$Java8 # 接口類 -keep public class com.xx.api.ApiService { *; } 注意 不保持接口類時會報「java.lang.IllegalArgumentException: Missing either [@GET](https://my.oschina.net/get) URL or [@Url](https://my.oschina.net/url) parameter.」
分三種狀況(base url爲"https://api.weibo.com/2/"):java
1. 動態url包含完整的scheme和host,直接使用動態url做爲最終的請求url。例如動態url爲"http://apis.baidu.com/apistore/weatherservice/weather",那麼最終的請求url也爲"http://apis.baidu.com/apistore/weatherservice/weather"。 2. 動態url包含該host,則使用base url的scheme鏈接動態url做爲最終的請求url。例如動態url爲"//apis.baidu.com/apistore/weatherservice/weather",那麼最終的請求url爲"https://apis.baidu.com/apistore/weatherservice/weather"。 3. 動態url不包含scheme和host,則將baseurl與動態url鏈接起來做爲最終的請求url,與在@GET後定義端點url一致。例如動態url爲"/apistore/weatherservice/weather",那麼最終的請求url爲"https://api.weibo.com/apistore/weatherservice/weather"。
注意api
[@GET](https://my.oschina.net/get) Observable<ResponseBody> executeGet( [@Url](https://my.oschina.net/url) String url, @HeaderMap Map<String, String> headers, @QueryMap Map<String, String> maps); @GET("{url}") Observable<ResponseBody> executeGet( @Path("url") String url, @HeaderMap Map<String, String> headers, @QueryMap Map<String, String> maps); 以上寫法,url會被轉義(「/」別轉義爲「%2F」),致使上面規則失效,老是添加baseurl @GET("{url}") Observable<ResponseBody> executeGet( @Path(value ="url", encoded = true) String url, @HeaderMap Map<String, String> headers, @QueryMap Map<String, String> maps); 以上寫法,避免被轉移,正常
參考url
Retrofit之請求Url http://www.jianshu.com/p/be4007f8eac7 是時候客觀評價Retrofit了,Retrofit這幾點你必須明白! http://blog.csdn.net/sk719887916/article/details/53613263