美文网首页工作生活
MVPArms:Failed to call observer

MVPArms:Failed to call observer

作者: 晓晓桑 | 来源:发表于2019-07-02 15:55 被阅读0次

    bug:
    MVPArms的Fragment的persenter里面kindsBeanList为空。检查各项代码没有问题。

    @Inject     
    List<KindsBean> kindsBeanList;
    

    报错

     Process: com.tuan.shang.speedloans, PID: 16005
        java.lang.RuntimeException: Failed to call observer method
            at android.arch.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:225)
            at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:193)
            at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:184)
            at android.arch.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:36)
            at android.arch.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
            at android.arch.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:180)
            at com.jess.arms.mvp.BasePresenter.onStart(BasePresenter.java:85)
            at com.jess.arms.mvp.BasePresenter.<init>(BasePresenter.java:63)
    
     Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.addAll(java.util.Collection)' on a null object reference
            at com.tuan.shang.speedloans.mvp.presenter.HomePresenter.requestKindsList(HomePresenter.java:91)
            at com.tuan.shang.speedloans.mvp.presenter.HomePresenter.onCreate(HomePresenter.java:82)
            at java.lang.reflect.Method.invoke(Native Method)
            at android.arch.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:215)
                ... 44 more
    

    bug解决:fragment的presnter的OnLifecycleEvent绑定ON_START,不要绑定ON_CREATE

    @OnLifecycleEvent(Lifecycle.Event.ON_START)
        void onCreate() {
            requestKindsList();//打开 App 时自动加载列表
    
        }
    

    相关文章

      网友评论

        本文标题:MVPArms:Failed to call observer

        本文链接:https://www.haomeiwen.com/subject/gkxthctx.html