java.lang.IllegalStateException: Bindings already cleared.

今天突然出现下面这个问题。   

原因是在网络获取数据需要一定的时间,先对数据进行了clear 然后获取数据,导致这中间有一段时间 list size 为0 。

1、所以在网络请求 getData()的时候先不要clear list 

2、而是等到 getData() 完成之后,在去clear list 然后 list.addAll()

3、在adapter.notifyDataSetChanged();

--------- beginning of crash
2020-06-11 14:55:47.168 20726-20726/com.seeknature.audio E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.seeknature.audio, PID: 20726
    java.lang.RuntimeException: Unable to destroy activity {com.seeknature.audio/com.seeknature.audio.activity.MainActivity}: java.lang.IllegalStateException: Bindings already cleared.
        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5001)
        at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5030)
        at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:224)
        at android.app.ActivityThread.main(ActivityThread.java:7520)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
     Caused by: java.lang.IllegalStateException: Bindings already cleared.
        at com.seeknature.audio.fragment.Fragment2_3_ViewBinding.unbind(Fragment2_3_ViewBinding.java:28)
        at com.seeknature.audio.base.BaseFragment.onDestroy(BaseFragment.java:144)
        at android.support.v4.app.Fragment.performDestroy(Fragment.java:2699)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1591)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
        at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
        at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:3260)
        at android.support.v4.app.Fragment.performDestroy(Fragment.java:2694)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1591)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
        at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
        at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:3260)
        at android.support.v4.app.FragmentController.dispatchDestroy(FragmentController.java:274)
        at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:419)
        at android.support.v7.app.AppCompatActivity.onDestroy(AppCompatActivity.java:210)
        at com.seeknature.audio.base.BaseActivity.onDestroy(BaseActivity.java:811)
        at com.seeknature.audio.activity.MainActivity.onDestroy(MainActivity.java:1355)
        at android.app.Activity.performDestroy(Activity.java:8180)
        at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1342)
        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4986)
        at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5030) 
        at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44) 
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:224) 
        at android.app.ActivityThread.main(ActivityThread.java:7520) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
2020-06-11 14:55:47.171 20726-20726/com.seeknature.audio E/MQSEventManagerDelegate: failed to get MQSService.

 

你可能感兴趣的:(异常总结)