Reputation: 755
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'
Upvotes: 2
Views: 3114
Reputation: 4297
If you are using multidex
then also this problem might occur. But in lower version of the phones.
All you need to do is follow the procedures given over here:
https://stackoverflow.com/a/26627133/842607
Upvotes: 4
Reputation: 755
Okay, I can explain how I tried to fix, and hopefully it helps someone. I tried clean > rebuild few times, I've removed my libraries which was installed in c:users\userName.gradle\caches\modules\files-2.1, then tried to check dependencies to see if there is duplicates (some libraries can include each other internally), and I always cleaned and rebuilt. In the end I re-downloaded the whole Android environment.
However, for some reason, I remembered i didn't apply the multidex and i did it, and it worked, and that what worked for me. Which i still don't understand why, because it worked on different pc without multidex
Upvotes: 1
Reputation: 2615
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.
Upvotes: 2