CreateRendererWithContext .net MAUI android

Anonymous
2023-06-01T09:46:36.4266667+00:00
0

i am re using xamarin forms renderer in MAUI. while creating renderer with "CreateRendererWithContext" method getting exception.

below is my code.


using AndroidPlatform = Microsoft.Maui.Controls.Compatibility.Platform.Android.Platform;
static IVisualElementRenderer GetRenderer(VisualElement element, Context context)
        {
            var renderer = AndroidPlatform.GetRenderer(element);
            if (renderer == null)
            {
                renderer = AndroidPlatform.CreateRendererWithContext(element, context);
                AndroidPlatform.SetRenderer(element, renderer);
            }

            return renderer;
        }
on this line getting exception. renderer = AndroidPlatform.CreateRendererWithContext(element, context);

Exception details :

{Android.Views.InflateException: Binary XML file line #1 in com.companyname.librarytestappmaui:layout/fragment_backstack: Error inflating class androidx.fragment.app.FragmentContainerView ---> Java.Lang.IllegalStateException: FragmentManager is already executing transactions …} Android.Views.InflateException

could someone please help on this.
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,223 questions
{count} votes