Android studio 编译报错:Supertypes of the following classes cannot be resolved. Please make sure you have the required dependence
Android studio版本:
具体操作:
1、新增一个module,将Java-WebSocket 导入moudle(
implementation "org.java-websocket:Java-WebSocket:1.5.1"
);
2、新建类继承WebSocketClient:
public class JWebSocketClient extends WebSocketClient {
public JWebSocketClient(URI serverUri) {
super(serverUri, new Draft_6455());
}
@Override
public void onOpen(ServerHandshake handshakedata) {
Log.e("JWebSocketClient", "onOpen()");
}
@Override
public void onMessage(String message) {
Log.e("JWebSocketClient", "onMessage()");
}
@Override
public void onClose(int code, String reason, boolean remote) {
Log.e("JWebSocketClient", "onClose()");
}
@Override
public void onError(Exception ex) {
Log.e("JWebSocketClient", "onError()");
}
}
3、编译。
编译时报错:Supertypes of the following classes cannot be resolved. Please make sure you have the required dependence
修改方法:1、file->Invalidate Caches/Restart;
2、如果还是报错 Build->Clear Project / Rebuild Project;
3、如果还是报错 重启电脑。