PrismLibrary / Prism

Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, Xamarin Forms, and Uno / Win UI Applications..

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] [Android] Open app from url scheme crashes app

MadsMY opened this issue · comments

Description

[Prism.Maui 8.1.273 pre] [Android]

Whenever the app is opened the regular way (by pressing app icon on mobile) we get a normal boot and all works fine.
But as soon we try to open the app through an url scheme (from outside the app) we get the message Set MainPage or override CreateWindow and the app crashes.

Addition:

Code works fine on iOS

Steps to Reproduce

  1. Open app through app icon
  2. Put app in background
  3. Open the app through url scheme
  4. Get crash (Set MainPage or override CreateWindow)

Platform with bug

.NET MAUI

Affected platforms

Android

Did you find any workaround?

In App.xaml.cs override CreateWindow and whenever MainPage is null set it with one of your pages.
If that isnt always the correct page you needed to navigate to you can do your navigation from there (less than ideal, but it works)

Relevant log output

System.NotImplementedException: Either set MainPage or override CreateWindow.
  at Microsoft.Maui.Controls.Application.CreateWindow(IActivationState activationState) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Application\Application.Impl.cs:129
  at Microsoft.Maui.Controls.Application.Microsoft.Maui.IApplication.CreateWindow(IActivationState activationState) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Application\Application.Impl.cs:47
  at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Activity activity, IApplication application, Bundle savedInstanceState) in D:\a\_work\1\s\src\Core\src\Platform\Android\ApplicationExtensions.cs:44
  at Microsoft.Maui.MauiAppCompatActivity.OnCreate(Bundle savedInstanceState) in D:\a\_work\1\s\src\Core\src\Platform\Android\MauiAppCompatActivity.cs:32
  at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Android.App.Activity.cs:2816
  at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:121

I guess you're using a very old version of Prism.Maui. What about trying the latest pre-release on nuget.org or from the latest private nuget feed?

Im aware that im using an old version, but the app is still build on .NET 7 and hence doesnt support any higher version Prism.MAUI since from 9 and on is .NET 8.

Changing towards these brings a fair amount of work, not everything works then.

And this is a bug I would like to fix before switching to NET 8

I've tried doing this but resulted in similar errors/crashes. Perhaps this is partially because of the new way is implemented (no longer relying on App.xaml.cs to inherit from PrismApplication (the old way) and the new way of adding Segments when setting up .UsePrism in MauiProgram?

If you can reproduce it with .NET 8 please provide a reproduction of it. But we will not be looking into a bug that is pre net8.0 unless you have an Enterprise Support agreement in place.