Oleg Skidan Oleg Skidan - 10 months ago 161
Android Question

Okhttp3 is not see WebSocket interface in Android Studio

I get some problems with okhttp3 lib.

I add in my gradle file dependency:

compile 'com.squareup.okhttp3:okhttp:3.4.1'

After that, I try to create webSocket connection like here okhttp websocket example, but Android Studio don't see any classes and interfaces like

import okhttp3.WebSocket;
import okhttp3.WebSocketListener;

But I know, that this files exist in okhttp3. Can anybody explain, what I did wrang?

If we see in okhttp javadoc we can not find these classes. But they are in github.

Answer Source

You have to add the okhttp-ws module.

compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'

WebSockets are moving out of a separate, experimental artifact and into the core okhttp artifact for the next release, 3.5.0, which is what you see if you look at GitHub.