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.
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.