简体   繁体   中英

Android Issue with Retrofit and RxJava

I get a following error when I call subscribe on an Observable that was returned from retrofit api call.

I think it might be a Proguard issue. After much googling, I didn't find any fixes.

Versions used

Retrofit used 1.6.1

RxJava used 0.16.1

Let me know if more information is needed.

09-06 18:38:16.882    8101-8101/co.spaceapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: co.spaceapp, PID: 8101
rx.util.OnErrorNotImplementedException: retrofit.RxSupport$1
        at rx.Observable$2.onError(Observable.java:376)
        at rx.operators.SafeObserver._onError(SafeObserver.java:118)
        at rx.operators.SafeObserver.onError(SafeObserver.java:94)
        at rx.operators.SafeObserver.onNext(SafeObserver.java:106)
        at rx.Notification.accept(Notification.java:121)
        at  rx.operators.OperationObserveOn$ObserveOn$Observation$SourceObserver$2.call(OperationObserveOn.java:117)
        at rx.operators.OperationObserveOn$ObserveOn$Observation$SourceObserver$2.call(OperationObserveOn.java:112)
        at rx.Scheduler$3.call(Scheduler.java:163)
        at rx.Scheduler$3.call(Scheduler.java:159)
        at rx.android.schedulers.HandlerThreadScheduler$1.run(HandlerThreadScheduler.java:72)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5001)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.NoClassDefFoundError: retrofit.RxSupport$1
        at retrofit.RxSupport.createRequestObservable(RxSupport.java:32)
        at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:263)
        at $Proxy1.getMoments(Native Method)
        at co.spaceapp.activity.DetailSpaceActivity.getMoments(DetailSpaceActivity.java:294)
        at   co.spaceapp.activity.DetailSpaceActivity.getLatestMoments(DetailSpaceActivity.java:276)
        at co.spaceapp.activity.DetailSpaceActivity.access$200(DetailSpaceActivity.java:81)
        at co.spaceapp.activity.DetailSpaceActivity$2.call(DetailSpaceActivity.java:249)
        at co.spaceapp.activity.DetailSpaceActivity$2.call(DetailSpaceActivity.java:240)
        at rx.Observable$2.onNext(Observable.java:381)
        at rx.operators.SafeObserver.onNext(SafeObserver.java:102)

I've fixed it.

The problem was that rxjava-core and rxjava-android were old versions.

Change from:

compile 'com.netflix.rxjava:rxjava-core:0.16.1'

compile 'com.netflix.rxjava:rxjava-android:0.16.1'

To:

compile 'com.netflix.rxjava:rxjava-core:0.20.3'

compile 'com.netflix.rxjava:rxjava-android:0.20.3'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM