diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7049.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7049.cs
new file mode 100644
index 000000000..5d8aa543d
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7049.cs
@@ -0,0 +1,58 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using NUnit.Framework;
+using Xamarin.UITest;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve (AllMembers=true)]
+ [Issue (IssueTracker.Github, 7049, "Null reference exception on some Android devices - Xamarin.Forms.Platform.Android.PageRenderer.Xamarin.Forms.Platform.Android.IOrderedTraversalController.UpdateTraversalOrder", PlatformAffected.Android)]
+ public class Issue7049 : TestContentPage
+ {
+ const string ContinueButton = "ContinueButton";
+ const string View1 = "View1";
+ const string View2 = "View2";
+ const string View3 = "View3";
+
+ bool _flag = true;
+
+ protected override void Init()
+ {
+
+ var button = new Button { AutomationId = ContinueButton, Text = "Continue" };
+ button.Clicked += (_, __) =>
+ {
+ var view = _flag ?
+ (View)new Entry { AutomationId = View2, Text = "Press 1 time to crash" } :
+ new Label { AutomationId = View3, Text = "I'm shown, bug fixed!" };
+ _flag ^= true;
+ (Content as StackLayout).Children[1] = view;
+ };
+ Content = new StackLayout
+ {
+ Children =
+ {
+ button,
+ new Label { AutomationId = View1, Text = "Press 2 times to crash" }
+ }
+ };
+ }
+
+#if UITEST && __ANDROID__
+ [Test]
+ [Description ("Test null reference in IOrderedTraversalController.UpdateTraversalOrder of Android PageRenderer")]
+ public void Issue7049TestsNullRefInUpdateTraversalOrder()
+ {
+ RunningApp.WaitForElement(View1);
+ RunningApp.Tap(ContinueButton);
+ RunningApp.WaitForElement(View2);
+ RunningApp.Tap(ContinueButton);
+ RunningApp.WaitForElement(View3);
+ RunningApp.Tap(ContinueButton);
+ }
+#endif
+ }
+}
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index f4c5cfddd..7dece809b 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -22,6 +22,7 @@
Code
+
diff --git a/Xamarin.Forms.Platform.Android/Renderers/PageRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/PageRenderer.cs
index 6f7decefa..1db606af1 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/PageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/PageRenderer.cs
@@ -187,7 +187,7 @@ namespace Xamarin.Forms.Platform.Android
!(
child is VisualElement ve && ve.IsTabStop
&& AutomationProperties.GetIsInAccessibleTree(ve) != false // accessible == true
- && ve.GetRenderer().View is ITabStop tabStop)
+ && ve.GetRenderer()?.View is ITabStop tabStop)
)
continue;
@@ -218,4 +218,4 @@ namespace Xamarin.Forms.Platform.Android
OrderedTraversalController.UpdateTraversalOrder();
}
}
-}
\ No newline at end of file
+}