kotlin

kotlin bug: Parameter specified

2019-12-11  本文已影响0人  月未雪

kotlin bug: java.lang.IllegalArgumentException: Parameter specified as non-null is null

错误日志

E/CrashHandler: In thread: Thread[main,5,main]
UncaughtException detected: java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.
at io.reactivex.android.schedulers.HandlerSchedulerScheduledRunnable.run(HandlerScheduler.java:111) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6211) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInitMethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:793)
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter object
at io.reactivex.internal.operators.observable.ObservableObserveOnObserveOnObserver.drainNormal(ObservableObserveOn.java:200) at io.reactivex.internal.operators.observable.ObservableObserveOnObserveOnObserver.run(ObservableObserveOn.java:252)
at io.reactivex.android.schedulers.HandlerSchedulerScheduledRunnable.run(HandlerScheduler.java:109) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6211) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInitMethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:793)

      代码:
      RetrofitApi.getInstance().saveLocationMsg(regionProvinceId, regionCityId, regionAreaId, purchaseName, purchasePhone, userAddress).
                subscribeOn(Schedulers.io()).
                observeOn(AndroidSchedulers.mainThread()).
                subscribe(object : RxSubcriber<Any>() {

            override fun onSuccess(t: Any?) {
                if (isViewAttached) {
                    mMvpView.saveCallBack(t)
                }
            }
    
            override fun onError(e: Throwable?) {
                if (isViewAttached) {
                }
                super.onError(e)
            }
        })
    }

解决办法: 回调方法参数后面声明加? 允许为null

上一篇下一篇

猜你喜欢

热点阅读