I am trying to use Retrofit in one of me projects. I am facing an error with (new OkClient(new OkHttpClient()))
 RestAdapter adapter = new RestAdapter.Builder()
                 .setEndpoint(Constants.GET_API_URL_BASE)
                 .setLogLevel(RestAdapter.LogLevel.FULL)
                 .setClient(new OkClient(new OkHttpClient()))
                 .build();
         apiGet = adapter.create(ApiCalls.class);
The error, underline in red, is on
(new OkHttpClient())
* OkClient(com.squareup.okhttp.OkhttpClient) in OkClient cannot be applied to (okhttp3.OkhttpClient)*
These are my dependences:
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'net.danlew:android.joda:2.7.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
Any idea?.
Thanks
You can use OkHttp3 with Retrofit 1.9 thanks to Jake Wharton and his retrofit1-okhttp3-client
With this library you just need to modify the setClient() in your RestAdapter.Builder to use Ok3Client instead of OkClient.
The code should be like this:
RestAdapter adapter = new RestAdapter.Builder()
             .setEndpoint(Constants.GET_API_URL_BASE)
             .setLogLevel(RestAdapter.LogLevel.FULL)
             .setClient(new Ok3Client(new OkHttpClient()))
             .build();
Here you can find more information about how to use it.
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