PSP PSP - 29 days ago 20
Android Question

FATAL EXCEPTION: main java.lang.NoClassDefFoundError: rx.plugins.RxJavaHooks

In my application after successfully login, loading data through retrofit library.
from last two days i founded one major issue in my application. below android API level 21 application getting crashes i checked in console and logs. i got "FATAL EXCEPTION" due to no class def found error. same app working above android API level 23.

in

build.gradle
file

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
applicationId "com.example.rsukumar.gluser"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'

//dagger 2
compile 'com.google.dagger:dagger:2.0.2'
provided 'com.google.dagger:dagger-compiler:2.0'
provided 'javax.annotation:jsr250-api:1.0'
compile 'com.neenbedankt.gradle.plugins:android-apt:1.8'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'

//retrofit 2
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
}


enter image description here

My main question is why i'm getting above exception and error? that too in different Android API levels.

Answer Source

this problem can be related to multidex support for your application. Android Version < 21 do not support Multidex by default. You need to enhance your application. I followed the following instructions to resovle this problem for my applications API Level < 21