微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

没有找到类rx.android.schedulers.AndroidSchedulers

我在我的应用程序中同时使用rxjava / rxandroid和jackson-databind,但似乎两个库无法一起工作.当我尝试运行我的应用程序时,它返回以下错误

java.lang.classNotFoundException: rx.android.schedulers.AndroidSchedulers

这是我的gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsversion "23.0.2"

    defaultConfig {
        applicationId "myapp"
        minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK_VERSION)
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }


    packagingOptions {
        exclude 'meta-inf/LICENSE'
        exclude 'meta-inf/LICENSE.txt'
        exclude 'meta-inf/NOTICE'
    }

    lintOptions {
        abortOnError false
    }
}

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile filetree(dir: 'libs', include: ['*.jar'])
    compile 'com.pspdfkit:pspdfkit:2.0.1@aar'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.google.guava:guava:19.0'
    compile 'org.lucasr.twowayview:twowayview:0.1.4'
    compile 'com.joanzapata.pdfview:android-pdfview:1.0.2@aar'
    compile 'net.lingala.zip4j:zip4j:1.3.2'
    compile 'com.github.chrisbanes.photoview:library:1.2.4'
    compile 'com.makeramen:roundedimageview:2.2.1'
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'ch.acra:acra:4.7.0'

    compile 'io.reactivex:rxjava:1.1.0'
    compile 'io.reactivex:rxandroid:1.1.0'

    compile ('com.koushikdutta.ion:ion:2.+') {
        exclude (group: 'com.google.code.gson')
    }
    compile (project (':common'))

}

在公共项目中有一个杰克逊依赖,这使得应用程序产生这个错误

compile 'com.fasterxml.jackson.core:jackson-databind:2.7.0-rc2'

有人有这个问题吗?有一个简单的解决方案吗?

解决方法:

问题来自于使用RxAndroid和multidex支持.对我有用的解决方案是添加android:name =“android.support.multidex.MultiDexApplication”
在清单中的应用程序级别.

如果您有类似android:name =“.MyApp”的内容,则覆盖attachBaseContext()方法

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

所有这些建议都来自

http://developer.android.com/tools/building/multidex.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐