M.Baraka M.Baraka - 23 days ago 22
Android Question

NoClassDefFoundError: rx.subscriptions.CompositeSubscription

I've an Android project where I used

rxjava
and
rxAndroid
. I suddenly started to get that crash
"NoClassDefFoundError: rx.subscriptions.CompositeSubscription"


I've tried to look it online but I couldn't find a solution

java.lang.ExceptionInInitializerError
at rx.plugins.RxJavaSchedulersHook.createIoScheduler(RxJavaSchedulersHook.java:84)
at rx.plugins.RxJavaSchedulersHook.createIoScheduler(RxJavaSchedulersHook.java:72)
at rx.schedulers.Schedulers.<init>(Schedulers.java:70)
at rx.schedulers.Schedulers.getInstance(Schedulers.java:47)
at rx.schedulers.Schedulers.newThread(Schedulers.java:108)
at com.myPackage.controllers.modelsControllers.CountriesController.loadCountries(CountriesController.java:121)
at com.myPackage.views.fragments.ChatFragment.onCreateView(ChatFragment.java:57)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:829)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
at android.app.BackStackRecord.run(BackStackRecord.java:635)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
at android.app.Activity.performStart(Activity.java:5017)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: rx.subscriptions.CompositeSubscription
at rx.internal.schedulers.CachedThreadScheduler$CachedWorkerPool.<init>(CachedThreadScheduler.java:48)
at rx.internal.schedulers.CachedThreadScheduler.<clinit>(CachedThreadScheduler.java:139)
at rx.plugins.RxJavaSchedulersHook.createIoScheduler(RxJavaSchedulersHook.java:84) 
at rx.plugins.RxJavaSchedulersHook.createIoScheduler(RxJavaSchedulersHook.java:72) 
at rx.schedulers.Schedulers.<init>(Schedulers.java:70) 
at rx.schedulers.Schedulers.getInstance(Schedulers.java:47) 
at rx.schedulers.Schedulers.newThread(Schedulers.java:108) 
at com.myPackage.controllers.modelsControllers.CountriesController.loadCountries(CountriesController.java:121) 
at com.myPackage.views.fragments.ChatFragment.onCreateView(ChatFragment.java:57) 
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:829) 
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035) 
at android.app.BackStackRecord.run(BackStackRecord.java:635) 
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397) 
at android.app.Activity.performStart(Activity.java:5017) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
at android.app.ActivityThread.access$600(ActivityThread.java:130) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4745) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
at dalvik.system.NativeStart.main(Native Method) 


I didn't really change anything in the classes which is throwing exception which confuse me.

In my build.gradle, I've compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'

in my observable, I send http request using okHttp, and the exact line that throws exception is

subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread());


I need any suggestion ^^, and if you have any question please let me know.

Also if possible, can anyone explain what does that crash even mean?
Thanks.

EDIT
my build.gradle have those

compile 'io.reactivex:rxandroid:1.2.1'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.4.0'
compile 'com.trello:rxlifecycle:0.6.1'
// If you want pre-written Activities and Fragments you can subclass as providers
compile 'com.trello:rxlifecycle-components:0.6.1'

compile 'com.mlsdev.rximagepicker:library:1.1.9'
compile 'com.github.zellius:rxlocationmanager:0.1.1'
compile 'com.sdoward:rxgooglemaps:1.0@aar'

Answer

NoClassDefFoundError often happens when the build tools and/or hot-swapping fails to update after changing dependencies.

Try a Build > Clean Project and then run again.