簡體   English   中英

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

[英]Java.lang.ClassNotFoundException: Class io.reactivex.functions.Action not found

我使用的是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客戶端時遇到了類似的問題。

請參閱下面的存儲庫以獲取解決方案,使用自定義端口和server-url替換server-url和端口號。

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

如果它能解決您的問題,請告訴我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM