无法在android中访问我的模块嵌套依赖项

Sin*_*imi 0 dependencies android module

我创建了一个具有类依赖关系的android模块,如下所示:

implementation 'com.squareup.moshi:moshi:1.5.0'
implementation 'com.neovisionaries:nv-websocket-client:2.3'
Run Code Online (Sandbox Code Playgroud)

我将此模块添加到我的项目中.当我想使用它时,它说"无法访问com.neovisionaries.Adapter".

1 - 为什么它无法访问因为我认为我的Async类在后台调用该方法?

2 - 我应该将该依赖项添加到我的项目中吗?

我的模块课程

public class Async extends WebSocketAdapter {
   ....
public Async() {
}

public static Async getInstance(Context context) {
    if (instance == null) {
        sharedPrefs = context.getSharedPreferences(AsyncConstant.Constants.PREFERENCE, Context.MODE_PRIVATE);
        moshi = new Moshi.Builder().build();
        instance = new Async();
    }
    return instance;
}


public void webSocketConnect(String socketServerAddress, final String appId) {
        WebSocketFactory webSocketFactory = new WebSocketFactory();
        webSocketFactory.setVerifyHostname(false);
        setAppId(appId);
        setServerAddress(socketServerAddress);
        try {
            webSocket = webSocketFactory
                    .setConnectionTimeout(TIMEOUT)
                    .createSocket(socketServerAddress)
                    .addListener(this);
            webSocket.connectAsynchronously();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }}
Run Code Online (Sandbox Code Playgroud)

MyPresenter类

public class SocketPresenter implements SocketContract.presenter {

private Async async;
private SocketContract.view view;
@Override
    public void connect(String socketServerAddress, String appId) {
        async.webSocketConnect(socketServerAddress, appId);
    }
Run Code Online (Sandbox Code Playgroud)

此行有一个错误async.webSocketConnect(socketServerAddress, appId);,表示websocketConnect无法访问我的neseted模块依赖.

Sir*_*lot 8

compile不推荐使用Gradle 关键字时,它被两个新关键字替换:implementationapi.该implementation关键字使您的依赖内部而api暴露他们像老compile关键字一样.因此,您应该使用api而不是implementation.

请参阅文档中的更多详细信息.