retrofit
Retrofit2, maven project, Illegal reflective access warning
There was an issue filed about this, to which one of the Retrofit maintainers responded: The reflection works around a bug in the JDK which was fixed in 14 but it’s only used for default methods. As it’s only a warning, it’s not preventing your call from working. So your options are either to stick … Read more
Simulate no network using Retrofit and MockWebServer
Retrofit has a retrofit-mock module which offers a MockRestAdapter class whose purpose is to simulate network delay and errors. This is a used in conjunction with the normal RestAdapter to create an instance of your service. You can see a full example in the samples/mock-github-client/ folder of the repo: https://github.com/square/retrofit/tree/parent-1.9.0/retrofit-samples/mock-github-client MockRestAdapter offers these APIs: setDelay … Read more
Retrofit and OkHttp gzip decode
Replace this: @Headers({ “Accept-Encoding: gzip, deflate”, “Content-Type: application/json;charset=utf-8”, “Accept: application/json” }) With this: @Headers({ “Content-Type: application/json;charset=utf-8”, “Accept: application/json” }) When you provide your own Accept-Encoding header you’re instructing OkHttp that you want to do your own decompression. By omitting it, OkHttp will take care of both adding the header and the decompression.
Retrofit2.0 gets MalformedJsonException while the json seems correct?
Finally I solved my problem which is not related to the json lenient mode, something wrong with my POST response (there some other non json output before the json data). Here is the response from JakeWharton regarding how to set Gson lenient mode: make sure that you have:compile ‘com.google.code.gson:gson:2.6.1’ Gson gson = new GsonBuilder() .setLenient() … Read more