Oleg Skidan
Oleg Skidan

Reputation: 617

Okhttp3 is not see WebSocket interface in Android Studio

I get some problems with okhttp3 lib.

I added the following line in my gradle file dependency:

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

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

import okhttp3.WebSocket;
import okhttp3.WebSocketListener;

But I know that these files exist in okhttp3. Can anybody explain what I did wrong?

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

Upvotes: 2

Views: 2730

Answers (2)

Sachin Bhangale
Sachin Bhangale

Reputation: 1

Oct2019:

I have tried below line/version and works for me:

implementation("com.squareup.okhttp3:okhttp:4.2.1")

reference: https://github.com/square/okhttp

Upvotes: -1

Jake Wharton
Jake Wharton

Reputation: 76115

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.

Upvotes: 8

Related Questions