xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] [Android] [Shell] Crash with "Fragment already added: ShellContentFragment" #15030

Open greg84 opened 2 years ago

greg84 commented 2 years ago

Description

I've seen three reports from app in production on Android devices in the last two weeks with the following error:

java.lang.IllegalStateException: Fragment already added: ShellContentFragment

It seems this occurs when an attempt is made to add a fragment to a view more than once. The Android documentation (https://developer.android.com/guide/fragments/create) suggests only adding the fragment once, as when a configuration change occurs an existing fragment is restored from saved state. It therefore may be necessary to add a check before adding the ShellContentFragment.

This is the stack trace:

androidx.fragment.app.FragmentStore.addFragment FragmentStore.java:91
androidx.fragment.app.FragmentManager.addFragment FragmentManager.java:1713
androidx.fragment.app.BackStackRecord.executeOps BackStackRecord.java:415
androidx.fragment.app.FragmentManager.executeOps FragmentManager.java:2404
androidx.fragment.app.FragmentManager.executeOpsTogether FragmentManager.java:2162
androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute FragmentManager.java:2100
androidx.fragment.app.FragmentManager.execPendingActions FragmentManager.java:2002
androidx.fragment.app.FragmentManager$5.run FragmentManager.java:524
android.os.Handler.handleCallback Handler.java:742
android.os.Handler.dispatchMessage Handler.java:95
android.os.Looper.loop Looper.java:154
android.app.ActivityThread.main ActivityThread.java:5527
java.lang.reflect.Method.invoke Method.java
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run ZygoteInit.java:739
com.android.internal.os.ZygoteInit.main ZygoteInit.java:629

Steps to Reproduce

  1. Add shell to app, release app
  2. Add AppCenter telemetry
  3. Wait for Android crash reports

Expected Behavior

App is stable.

Actual Behavior

App crashes intermittently. Although with very low overall impact.

Basic Information

Environment

Show/Hide Visual Studio info ``` ```

Build Logs

Screenshots

Reproduction Link

Workaround

Anujai1 commented 2 years ago

Hi @greg84 Did you solve this? If yes. What is the solution?

drlivsi commented 1 year ago

The same error :(