Could not find class rx.android.schedulers.AndroidSchedulers

I use both rxjava / rxandroid and jackson-databind in my application, but it seems that both libraries cannot work together. When I try to run my application, it returns the following error:

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

here is my gradle file:

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'))

}

inside the general project there is a Jackson dependency that makes the application produce this error:

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

Has anyone had this problem? Is there a simple solution?

+4
source share
1 answer

The problem arises due to the use of RxAndroid and multidex support. The solution that worked for me was to add android:name="android.support.multidex.MultiDexApplication" at the application level in the manifest.

- android:name=".MyApp", attachBaseContext()

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

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

+5

Source: https://habr.com/ru/post/1622989/


All Articles