YoKeyword / Fragmentation

[DEPRECATED] A powerful library that manage Fragment for Android
Apache License 2.0
9.73k stars 2.12k forks source link

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference #1228

Closed Lemon-666-byte closed 4 years ago

Lemon-666-byte commented 4 years ago

java.lang.RuntimeException: Unable to destroy activity {com.app.car.manager/com.ui.main.activity.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5176) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5195) at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:39) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2199) at android.os.Handler.dispatchMessage(Handler.java:112) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7625) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference at androidx.fragment.app.Fragment.performDetach(Fragment.java:2849) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1034) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659) at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManagerImpl.java:2644) at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:329) at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:366) at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:233) at com.trello.rxlifecycle3.components.support.RxAppCompatActivity.onDestroy(RxAppCompatActivity.java:97) at com.app.common.base.MySupportActivity.onDestroy(MySupportActivity.java:52) at com.app.common.base.BaseActivity.onDestroy(BaseActivity.java:302) at android.app.Activity.performDestroy(Activity.java:7737) at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1327) at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5161) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5195)  at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:39)  at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2199)  at android.os.Handler.dispatchMessage(Handler.java:112)  at android.os.Looper.loop(Looper.java:216)  at android.app.ActivityThread.main(ActivityThread.java:7625) 

Lemon-666-byte commented 4 years ago

o

zeeshanaslam78 commented 4 years ago

How did you fix ?

lihuixingbj commented 4 years ago

fixed 可以参考: https://www.jianshu.com/p/d3fa8f23cf68