I'm using framework Retrofit for the first time in my Android project. It handles communication with a backend. Now the strangest part is that on Android 4.4 everything works like a charm. On every version below. I get a RetrofitError type java.io.EOFException. So it fails the first time and then when I push on the retry button it works. So Why is it failing the first time?
I want to fix this because it is annoying that users needs to click retry...
Does someone got a solution for this?
I found a solution. In Android 4.4 they work with OkHttpclient so thats the reason why it is working on 4.4 and not on the older Android versions.
To solve this add a dependency in gradle:
compile 'com.squareup.okhttp:okhttp-tests:1.5.1'
and create a new client like this:
OkHttpClient client = new OkHttpClient();
add that new client to the restadapter to use this:
setClient(new OkClient(client))
The error should be solved now.
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