gpt4 book ai didi

Java.lang.ClassNotFoundException : Class io. 未找到reactivex.functions.Action

转载 作者:行者123 更新时间:2023-12-02 06:07:38 26 4
gpt4 key购买 nike

我正在使用 rxjava 版本 v-2.2.6 和 naiksoftware/stompprotocolandroid v-1.6.4

我不断收到此错误

java.lang.ClassNotFoundException: Class io.reactivex.functions.Action not found   

任何时候我添加这个库实现

'com.github.NaikSoftware:StompProtocolAndroid:1.5.2' 到我的 build.gradle 文件,这是为什么?

public void connectStomp(View view) {

List<StompHeader> headers = new ArrayList<>();
headers.add(new StompHeader(LOGIN, "guest"));
headers.add(new StompHeader(PASSCODE, "guest"));

//mStompClient.withClientHeartbeat(10000).withServerHeartbeat(10000);

resetSubscriptions();

Disposable dispLifecycle = mStompClient.lifecycle()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(lifecycleEvent -> {
switch (lifecycleEvent.getType()) {
case OPENED:
Log.e(TAG, "Stomp connection opened");
//toast("Stomp connection opened");
break;
case ERROR:
Log.e(TAG, "Stomp connection error", lifecycleEvent.getException());
//toast("Stomp connection error");
mStompClient.reconnect();
break;
case CLOSED:
Log.e(TAG, "Stomp connection closed");
mStompClient.disconnect();
resetSubscriptions();
//toast("Stomp connection closed");
// mStompClient.connect();
break;
case FAILED_SERVER_HEARTBEAT:
Log.e(TAG, "Stomp connection opened");
//toast("Stomp failed server heartbeat");
break;
}
}, throwable -> {
Log.e(TAG, "Error on subscribe topic", throwable);
});

compositeDisposable.add(dispLifecycle);

// Receive greetings
Disposable dispTopic = mStompClient.topic("/topic/greetings")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(topicMessage -> {
Log.d(TAG, "Received " + topicMessage.getPayload());
//addItem(mGson.fromJson(topicMessage.getPayload(), EchoModel.class));
}, throwable -> {
Log.e(TAG, "Error on subscribe topic", throwable);
});

compositeDisposable.add(dispTopic);

mStompClient.connect(headers);

}

最佳答案

NaikSoftware/StompProtocolAndroid 库未使用更新的代码,我在 Android 中集成 stomp 客户端时遇到了类似的问题。

请参阅下面的存储库以获取解决方案,将服务器 URL 和端口号替换为您的自定义端口和服务器 URL。

repo -https://github.com/NaikSoftware/StompProtocolAndroid

如果它解决了您的问题,请告诉我。

关于Java.lang.ClassNotFoundException : Class io. 未找到reactivex.functions.Action,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55932450/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com