App got crashes on using Prism 9.0.271-pre on app launch #2981
Unanswered
sunilsolanki-alight
asked this question in
.NET MAUI
Replies: 1 comment
-
You have a bug in your code. There are a few ways that you can capture the exception that is causing the initial navigation to fail.
public static MauiApp CreateMauiApp() =>
MauiApp.CreateBuilder()
.UseMauiApp<App>()
.UsePrism(prism => prism
.AddGlobalNavigationObserver(context => context.Subscribe(x =>
{
// This uses Prism.Maui.Rx
if (x.Type == NavigationRequestType.Navigate)
Console.WriteLine($"Navigation: {x.Uri}");
else
Console.WriteLine($"Navigation: {x.Type}");
var status = x.Cancelled ? "Cancelled" : x.Result.Success ? "Success" : "Failed";
Console.WriteLine($"Result: {status}");
if (status == "Failed" && !string.IsNullOrEmpty(x.Result?.Exception?.Message))
Console.Error.WriteLine(x.Result.Exception.Message);
}))
.OnAppStart(navigationService => navigationService.CreateBuilder()
.AddSegment<SplashPageViewModel>()
.NavigateAsync(HandleNavigationError))
)
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.Build();
private static void HandleNavigationError(Exception ex)
{
Console.WriteLine(ex);
System.Diagnostics.Debugger.Break();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
App got crashes on using Prism 9.0.271-pre on app launch. where as on debugger it works
Fatal Exception: android.runtime.JavaProxyThrowable: [Microsoft.Maui.Controls.InvalidNavigationException]: Expected Navigation Failed. No Root Window has been created.
at Prism.Navigation.PrismWindowManager.CreateWindow()
at Microsoft.Maui.Controls.Application.CreateWindow()
at Microsoft.Maui.Controls.Application.Microsoft.Maui.IApplication.CreateWindow()
at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow()
at Microsoft.Maui.MauiAppCompatActivity.OnCreate()
at AlightMobile.MainActivity.OnCreate()
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_()
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V()
at crc649435415b1c7c6b8b.MainActivity.n_onCreate(MainActivity.java)
at crc649435415b1c7c6b8b.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:8129)
Beta Was this translation helpful? Give feedback.
All reactions