{"record":{"id":"8a9c16077a012936","repo":"dotnet/maui","slug":"pushasync-is-not-supported-globally-on-android-pl","errorCode":null,"errorMessage":"PushAsync is not supported globally on Android, please use a NavigationPage.","messagePattern":"PushAsync is not supported globally on Android, please use a NavigationPage\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/Android/AppCompat/Platform.cs","lineNumber":192,"sourceCode":"\n\t\tTask INavigation.PopToRootAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopToRootAsync(true);\n\t\t}\n\n\t\tTask INavigation.PopToRootAsync(bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PopToRootAsync is not supported globally on Android, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask INavigation.PushAsync(Page root)\n\t\t{\n\t\t\treturn ((INavigation)this).PushAsync(root, true);\n\t\t}\n\n\t\tTask INavigation.PushAsync(Page root, bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PushAsync is not supported globally on Android, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask INavigation.PushModalAsync(Page modal)\n\t\t{\n\t\t\treturn ((INavigation)this).PushModalAsync(modal, true);\n\t\t}\n\n\t\tasync Task INavigation.PushModalAsync(Page modal, bool animated)\n\t\t{\n\t\t\tCurrentPageController?.SendDisappearing();\n\t\t\tUpdateAccessibilityImportance(CurrentPageController as Page, ImportantForAccessibility.NoHideDescendants, false);\n\n\t\t\t_navModel.PushModal(modal);\n\n\t\t\tTask presentModal = PresentModal(modal, animated);\n\n\t\t\tawait presentModal;\n","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/Android/AppCompat/Platform.cs#L174-L210","documentation":"Thrown by the Platform class's explicit INavigation.PushAsync(bool) implementation. On Android, the global platform does not support non-modal page pushes; PushAsync requires a NavigationPage. Only PushModalAsync is available at the platform level.","triggerScenarios":"Calling await Application.Current.MainPage.Navigation.PushAsync(page) on Android when MainPage is not a NavigationPage. This is the most commonly hit navigation error when porting iOS-first apps to Android.","commonSituations":"Shared MVVM navigation code that calls Navigation.PushAsync from a ViewModel without ensuring a NavigationPage root. Sample/template apps that omit NavigationPage.","solutions":["Set MainPage to a NavigationPage (e.g., new NavigationPage(new MainPage())) so PushAsync works.","Use PushModalAsync if a modal presentation is acceptable.","In shared navigation services, detect the platform or check for a NavigationPage before choosing PushAsync vs PushModalAsync."],"exampleFix":"// before\nApplication.Current.MainPage = new MainPage();\nawait Application.Current.MainPage.Navigation.PushAsync(new DetailPage()); // throws on Android\n\n// after\nApplication.Current.MainPage = new NavigationPage(new MainPage());\nawait Application.Current.MainPage.Navigation.PushAsync(new DetailPage());","handlingStrategy":"validation","validationCode":"// Ensure a NavigationPage root before PushAsync.\nif (!(Application.Current.MainPage is NavigationPage))\n    Application.Current.MainPage = new NavigationPage(Application.Current.MainPage);\nawait Application.Current.MainPage.Navigation.PushAsync(newPage);","typeGuard":"static bool CanPushAsync(Page root) => root is NavigationPage;","tryCatchPattern":null,"preventionTips":["Set MainPage = new NavigationPage(rootPage) in shared startup code.","Build a cross-platform INavigationService that wraps PushAsync and falls back to PushModalAsync with a warning.","Document in the app's architecture guide that Android requires NavigationPage for stack navigation."],"tags":["android","navigation","pushasync","navigationpage","platform"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}