ANDROID STUDIO ERROR LOG:
Here, App using the latest gradle as below implementation 'androidx.core:core:1.1.0-alpha03'
I have compared crashing fragment with other fragment code and found the difference as below: Crashing fragment has method setRetainInstance(true); inside onCreateView() as shown in below snippet.
HOW TO REPLICATE THIS ISSUE:
MainActivity --> HomeFragment --> FirstFragment(crashing fragment) --> HomeFragment
MainActivity loads with HomeFragment which replaced by FirstFragment and then going back to HomeFragment. Then moving my app to background and crash happens with below exception.
Read More about setRetainInstance(true)
E/FragmentManager: Failure saving state: active AllStoresFragmentListV2{fd50037 (4a8b618e-a0a8-45d0-aa37-ba08393b8f68) id=0x7f08009c} was removed from the FragmentManager
01-09 11:34:42.768 19169-19169/com.android.app E/FragmentManager: Activity state:
01-09 11:34:42.805 4746-6075/? E/ExecutionCriteria: Package unavailable for task: com.google.android.apps.fitness/.api.services.summary.ActivitySummaryGcmTaskService{u=0 tag="ActivitySummaryGcmTaskService" trigger=window{period=1800s,flex=180s,earliest=-27143018s,latest=-27142838s} requirements=[NET_ANY] attributes=[PERSISTED,RECURRING] scheduled=-27144638s last_run=N/A jid=N/A status=PENDING retries=0 client_lib=MANCHEGO_GCM-10400000}
01-09 11:34:42.880 19169-19169/com.android.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.app, PID: 19169
java.lang.IllegalStateException: Failure saving state: active AllStoresFragmentListV2{fd50037 (4a8b618e-a0a8-45d0-aa37-ba08393b8f68) id=0x7f08009c} was removed from the FragmentManager
at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManagerImpl.java:2315)
at androidx.fragment.app.FragmentController.saveAllState(FragmentController.java:150)
at androidx.fragment.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:496)
at androidx.appcompat.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:511)
at android.app.Activity.performSaveInstanceState(Activity.java:1348)
at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1290)
at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:4202)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3592)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3658)
at android.app.ActivityThread.access$1400(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1429)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5603)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
01-09 11:34:42.768 19169-19169/com.android.app E/FragmentManager: Activity state:
01-09 11:34:42.805 4746-6075/? E/ExecutionCriteria: Package unavailable for task: com.google.android.apps.fitness/.api.services.summary.ActivitySummaryGcmTaskService{u=0 tag="ActivitySummaryGcmTaskService" trigger=window{period=1800s,flex=180s,earliest=-27143018s,latest=-27142838s} requirements=[NET_ANY] attributes=[PERSISTED,RECURRING] scheduled=-27144638s last_run=N/A jid=N/A status=PENDING retries=0 client_lib=MANCHEGO_GCM-10400000}
01-09 11:34:42.880 19169-19169/com.android.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.app, PID: 19169
java.lang.IllegalStateException: Failure saving state: active AllStoresFragmentListV2{fd50037 (4a8b618e-a0a8-45d0-aa37-ba08393b8f68) id=0x7f08009c} was removed from the FragmentManager
at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManagerImpl.java:2315)
at androidx.fragment.app.FragmentController.saveAllState(FragmentController.java:150)
at androidx.fragment.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:496)
at androidx.appcompat.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:511)
at android.app.Activity.performSaveInstanceState(Activity.java:1348)
at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1290)
at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:4202)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3592)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3658)
at android.app.ActivityThread.access$1400(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1429)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5603)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
Here, App using the latest gradle as below implementation 'androidx.core:core:1.1.0-alpha03'
I have compared crashing fragment with other fragment code and found the difference as below: Crashing fragment has method setRetainInstance(true); inside onCreateView() as shown in below snippet.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setRetainInstance(true);
}
I come across the link which says not to use setRetainInstance : setRetainInstance - This can only be used with fragments not in the back stack
I removed the setRetainInstance(true) for crashing fragmnet; It's working now.setRetainInstance(true);
}
HOW TO REPLICATE THIS ISSUE:
MainActivity --> HomeFragment --> FirstFragment(crashing fragment) --> HomeFragment
MainActivity loads with HomeFragment which replaced by FirstFragment and then going back to HomeFragment. Then moving my app to background and crash happens with below exception.
java.lang.IllegalStateException: Failure saving state: active
FirstFragment{fd50037 (4a8b618e-a0a8-45d0-aa37-ba08393b8f68)
id=0x7f08009c} was removed from the FragmentManager
Read More about setRetainInstance(true)
No comments:
Post a Comment