{"record":{"id":"251f7afb0e9757c9","repo":"dotnet/maui","slug":"popasync-is-not-supported-globally-on-android-ple","errorCode":null,"errorMessage":"PopAsync is not supported globally on Android, please use a NavigationPage.","messagePattern":"PopAsync 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":129,"sourceCode":"\t\t}\n\n\t\tvoid INavigation.InsertPageBefore(Page page, Page before)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"InsertPageBefore is not supported globally on Android, please use a NavigationPage.\");\n\t\t}\n\n\t\tIReadOnlyList<Page> INavigation.ModalStack => _navModel.Modals.ToList();\n\n\t\tIReadOnlyList<Page> INavigation.NavigationStack => new List<Page>();\n\n\t\tTask<Page> INavigation.PopAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopAsync(true);\n\t\t}\n\n\t\tTask<Page> INavigation.PopAsync(bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PopAsync is not supported globally on Android, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask<Page> INavigation.PopModalAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopModalAsync(true);\n\t\t}\n\n\t\tTask<Page> INavigation.PopModalAsync(bool animated)\n\t\t{\n\t\t\tPage modal = _navModel.PopModal();\n\t\t\t((IPageController)modal).SendDisappearing();\n\t\t\tvar source = new TaskCompletionSource<Page>();\n\n\t\t\tIVisualElementRenderer modalRenderer = GetRenderer(modal);\n\t\t\tif (modalRenderer != null)\n\t\t\t{\n\t\t\t\tvar modalContainer = modalRenderer.View.Parent as ModalContainer;\n\t\t\t\tif (animated)","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/Android/AppCompat/Platform.cs#L111-L147","documentation":"Thrown by the Platform class's explicit INavigation.PopAsync(bool) implementation. The global Android platform only supports modal navigation; PopAsync (non-modal page pop) requires a NavigationPage. The message guides developers to use NavigationPage for stack-based navigation.","triggerScenarios":"Calling await Application.Current.MainPage.Navigation.PopAsync() on Android when MainPage is not a NavigationPage. The platform's Navigation property is returned instead of a NavigationPage's, so the explicit interface implementation throws.","commonSituations":"Shared navigation code calling PopAsync without a NavigationPage root. Cross-platform code that works on iOS but throws on Android because iOS's platform supports the operation.","solutions":["Wrap the root page in a NavigationPage so PopAsync resolves to the NavigationPage's implementation.","Use PopModalAsync for modal dismissal at the platform level.","Guard shared navigation code to check whether the current page is hosted in a NavigationPage before calling PopAsync."],"exampleFix":"// before\nawait Application.Current.MainPage.Navigation.PopAsync();\n\n// after (ensure NavigationPage root)\nApplication.Current.MainPage = new NavigationPage(new MainPage());\nawait NavigationPage.GetNavigationPage(Application.Current.MainPage).PopAsync();","handlingStrategy":"validation","validationCode":"// Before PopAsync, confirm a NavigationPage is in the hierarchy.\nstatic NavigationPage GetNavigationPage(Page page)\n{\n    return page as NavigationPage ?? NavigationPage.GetNavigationPage(page);\n}\n// Usage:\nvar np = GetNavigationPage(currentPage);\nif (np != null) await np.Navigation.PopAsync();\nelse await currentPage.Navigation.PopModalAsync();","typeGuard":"static bool HasNavigationPageHost(Page page) => page is NavigationPage || page?.Navigation is NavigationPage;","tryCatchPattern":null,"preventionTips":["Always wrap the root page in a NavigationPage on Android if you use PopAsync.","In shared code, branch on whether a NavigationPage is available before calling PopAsync.","Educate the team that global INavigation on Android is modal-only."],"tags":["android","navigation","popasync","navigationpage","platform"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}