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

无法访问android中的模块嵌套依赖项,android,module,dependencies,Android,Module,Dependencies,我创建了一个android模块,该模块具有如下类依赖关系: implementation 'com.squareup.moshi:moshi:1.5.0' implementation 'com.neovisionaries:nv-websocket-client:2.3' 我将此模块添加到我的项目中。当我想使用它时,它会说“无法访问com.neovisionaries.Adapter” 1-为什么它无法访问,因为我认为我的异步类在后台调用该方法 2-我应该将这种依赖性添加到我的项目中吗 我的

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

implementation 'com.squareup.moshi:moshi:1.5.0'
implementation 'com.neovisionaries:nv-websocket-client:2.3'
我将此模块添加到我的项目中。当我想使用它时,它会说“无法访问com.neovisionaries.Adapter”

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

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();
        }
    }}
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);
    }
MyPresenter类

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();
        }
    }}
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);
    }

此行有一个错误
async.webSocketConnect(socketServerAddress,appId)websocketConnect
的code>无法访问我的指定模块依赖项。

当Gradle
compile
关键字被弃用时,它被两个新关键字所取代:
实现
api
implementation
关键字将您的依赖项保持在内部,而
api
则像旧的
compile
关键字一样公开它们。因此,您应该使用
api
,而不是
implementation


有关更多详细信息,请参见。

乐于帮助:)@SirCodesalot模块具有其他依赖项(如api('io.socket:socket.io client:1.0.0')),并且该模块上载到Bintray上。上传成功后,我得到了一个maven依赖项,如下面的实现“com.sample.mysdk:1.5.0”。但是当我使用这个依赖项时,我并没有得到嵌套的依赖项类。