首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用AndroidSchedulers.mainThread()时发出

使用AndroidSchedulers.mainThread()时发出
EN

Stack Overflow用户
提问于 2019-03-21 06:39:14
回答 1查看 1.8K关注 0票数 0

在进行了一些升级之后,Android开始给我提供与版本号相关的错误,所以在修复这些错误的过程中,我遇到了与RXJava相关的问题,我在我的项目中使用了改进。

我得到的错误是.

代码语言:javascript
运行
复制
observeOn(io.reactivex.Schedulers) in Observable cannot be applied to (rx.Scheduler)

ManEmpAct.java

代码语言:javascript
运行
复制
    import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.dopay.onboarding.Constants;
import com.dopay.onboarding.DoPayApplication;
import com.dopay.onboarding.R;
import com.dopay.onboarding.data.AppPreferences;
import com.dopay.onboarding.enums.StartStopAppMonitor;
import com.dopay.onboarding.fragment.CreateEmployeeDetailsFragment;
import com.dopay.onboarding.fragment.EmployeeEditFragment;
import com.dopay.onboarding.modules.UserAccountManagementView;
import com.dopay.onboarding.refactor_fragments.CountryByPhoneNumberFragment;
import com.dopay.onboarding.refactor_fragments.TakePhotoFragment;
import com.dopay.onboarding.refactor_fragments.TakePhotoFragmentCamera2;
import com.dopay.onboarding.refactor_fragments.ViewImageFragment;
import com.dopay.onboarding.util.DialogUtil;
import com.dopay.onboarding.util.EventsTracker;
import com.dopay.onboarding.util.UIUtil;

//import rx.android.schedulers.AndroidSchedulers;

import io.reactivex.android.schedulers.AndroidSchedulers;
compositeSubscription.add(publishRelay.asObservable().observeOn(AndroidSchedulers.mainThread()).subscribe(iView -> {

}

应用程序中使用的全部依赖项列表,以防我找不到正确的build.gradle

代码语言:javascript
运行
复制
    compileSdkVersion 28
     minSdkVersion 21
     targetSdkVersion 26

    dependencies {

    //DEPENDENCIES RELATED TO RETROFIT, RXJAVA, RXANDROID
    implementation 'com.jenzz.appstate:adapter-rxjava2:3.0.1'
    implementation 'com.jakewharton.rxbinding2:rxbinding-recyclerview-v7:2.0.0'
    implementation 'com.laimiux.rxnetwork:rxnetwork:0.0.4'
    //Retrofit, RxJava and OkHttp,Gson,Dagger,ButterKnife.
    implementation 'com.squareup.retrofit2:retrofit:2.1.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
    implementation group: 'com.squareup.retrofit2', name: 'adapter-rxjava2', version: '2.2.0'
    implementation 'com.jakewharton.rxrelay2:rxrelay:2.0.0'
    implementation 'com.jakewharton.rxrelay:rxrelay:1.1.0'
    implementation group: 'io.reactivex.rxjava2', name: 'rxandroid', version: '2.0.1'
    implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
    implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'
    implementation 'com.squareup.retrofit2:retrofit-mock:2.1.0'
    testImplementation 'com.squareup.retrofit2:retrofit:2.1.0'
    testImplementation 'com.squareup.retrofit2:converter-gson:2.1.0'

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')

    implementation 'com.android.support:multidex:1.0.2'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v13:28.0.0'
    implementation 'com.jenzz.appstate:appstate:3.0.1'

    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation group: 'joda-time', name: 'joda-time', version: '2.3'
    implementation 'com.mikhaellopez:circularprogressbar:1.1.1'
    implementation 'io.realm:android-adapters:2.0.0'    
    implementation 'com.github.arimorty:floatingsearchview:2.1.1'
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'    
    implementation 'com.google.firebase:firebase-messaging:15.0.0'
    debugImplementation 'com.21buttons:fragment-test-rule:1.0.0'    
    implementation 'frankiesardo:icepick:3.1.0'
    annotationProcessor 'frankiesardo:icepick-processor:3.1.0'
    implementation 'io.michaelrocks:libphonenumber-android:8.9.0'
    implementation ('com.google.dagger:dagger:2.0.2'){
        exclude group: 'com.google.guava'
    }
    annotationProcessor ('com.google.dagger:dagger-compiler:2.0.2'){
        exclude group: 'com.google.guava'
    }
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    compileOnly 'javax.annotation:jsr250-api:1.0'
    implementation 'com.android.support:support-annotations:24.2.0'    
    implementation 'com.futuremind.recyclerfastscroll:fastscroll:0.2.5'    
    implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
    implementation 'com.jakewharton.timber:timber:4.5.1'
    implementation 'com.google.code.gson:gson:2.5'    
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.github.fafaldo:fab-toolbar:1.2.0'
    implementation 'com.instabug.library:instabug:8.1.1'
    implementation 'com.wdullaer:materialdatetimepicker:3.5.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'net.hockeyapp.android:HockeySDK:4.1.5'    
    implementation group: 'com.joooonho', name: 'selectableroundedimageview', version: '1.0.1'
    implementation 'com.mixpanel.android:mixpanel-android:5.+'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5'
    //releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
    testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.9.5'
    testImplementation 'com.google.dexmaker:dexmaker:1.1'
    testImplementation 'org.powermock:powermock-api-mockito:1.6.4'
    testImplementation 'org.powermock:powermock-module-junit4:1.6.4'
    testImplementation 'org.powermock:powermock-core:1.6.4'
    testImplementation 'org.powermock:powermock-module-junit4-rule:1.5.4'
    testImplementation 'org.powermock:powermock-classloading-base:1.6.4'
    testImplementation 'org.powermock:powermock-classloading-xstream:1.5.4'
    testImplementation 'org.powermock:powermock-module-testng:1.6.4'

}

分级版

代码语言:javascript
运行
复制
classpath 'com.android.tools.build:gradle:3.0.1'

无法弄清楚问题出在哪里,请你分享一下我可能做错了什么

谢谢R

EN

回答 1

Stack Overflow用户

发布于 2019-03-21 07:45:29

您将rxjava 2与rxjava 1调度程序混合在一起。可能to中继正在拉rxjava一个,您可以意外地从那里导入调度程序--我还没有确认这一点,但如果是的话,您可以简单地迁移到一个更新的to中继版本。有关更多细节,请查看自述文件。还请注意,这可能是任何其他库,而不是具体的be中继。

无论如何,从错误的完整路径中可以看出,rx.Scheduler (rxjava1调度器)不能用作期望io.reactivex.Schedulers (rxjava2调度器)的方法的参数。

我强烈建议将所有库更新为rxjava2,这样您就不会再发现这个问题了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55275011

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档