Okhttp3没有在Android Studio中看到WebSocket接口

时间:2021-03-03 20:53:45

I get some problems with okhttp3 lib.

我在okhttp3 lib中遇到了一些问题。

I added the following line in my gradle file dependency:

我在gradle文件依赖项中添加了以下行:

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

之后,我尝试创建webSocket连接,如okhttp websocket示例,但在Android Studio中,我没有看到任何类和接口,如

import okhttp3.WebSocket;
import okhttp3.WebSocketListener;

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

但我知道这些文件存在于okhttp3中。谁能解释我做错了什么?

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

如果我们在okhttp javadoc中看到我们找不到这些类。但他们在github。

1 个解决方案

#1


8  

You have to add the okhttp-ws module.

你必须添加okhttp-ws模块。

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.

WebSockets正在从一个单独的实验工件中移出,并进入下一个版本3.5.0的核心okhttp工件,如果你看看GitHub就会看到这个。

#1


8  

You have to add the okhttp-ws module.

你必须添加okhttp-ws模块。

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.

WebSockets正在从一个单独的实验工件中移出,并进入下一个版本3.5.0的核心okhttp工件,如果你看看GitHub就会看到这个。