Open Closed

7.2 and 7.1 Maui Android crashes in Release mode, but works in Debug. #5019


User avatar
0
davidlbrenchley@gmail.com created

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v7.2.1 - but happened in previous version of 7 as well

  • UI type: Blazor

  • DB provider: EF Core

  • Exception message and stack trace: *05-06 20:13:51.906 614 1817 I am_crash: [7774,0,com.companyname.abp_7_2.maui,552123972,android.runtime.JavaProxyThrowable,Autofac.Core.DependencyResolutionException: An exception was thrown while activating ABP_7_2.Maui.App -> ABP_7_2.Maui.AppShell. 05-06 20:13:51.906 614 1817 I am_crash: ---> Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(ABP_7_2.Maui.ViewModels.ShellViewModel)' on type 'AppShell'. 05-06 20:13:51.906 614 1817 I am_crash: ---> System.InvalidOperationException: NoServiceRegistered, Microsoft.Maui.Controls.Xaml.IRootObjectProvider 05-06 20:13:51.906 614 1817 I am_crash: at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider , Type ) 05-06 20:13:51.906 614 1817 I am_crash: at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredServiceIRootObjectProvider 05-06 20:13:51.906 614 1817 I am_crash: at ABP_7_2.Maui.Extensions.TranslateExtension.ProvideValue(IServiceProvider serviceProvider) 05-06 20:13:51.906 614 1817 I am_crash: at ABP_7_2.Maui.AppShell.InitializeComponent() 05-06 20:13:51.906 614 1817 I am_crash: at ABP_7_2.Maui.AppShell..ctor(ShellViewModel vm) 05-06 20:13:51.906 614 1817 I am_crash: at System.Object.lambda_method16(Closure , Object[] ) 05-06 20:13:51.906 614 1817 I am_crash: a^ 05-06 20:13:51.907 614 1817 W ActivityTaskManager: Force finishing activity com.companyname.abp_7_2.maui/crc646f116deefd72c39d.MainActivity 05-06 20:13:51.907 614 1817 I wm_finish_activity: [0,253247669,11,com.companyname.abp_7_2.maui/crc646f116deefd72c39d.MainActivity,force-crash]

  • Steps to reproduce the issue:" ABP Suite - Use a 7.1 or 7.2 - Application template; UI Framework: Blazor Server; Mobile - Maui. Then run the Maui project (Not the MauiBlazor project) in Release mode. (You may need to select Deploy option for the maui project).

The MauiBlazor project runs fine. I believe it has something to do with Shell interaction with ABP. Spent days and days on this thinking it was something in my project, but I was able to duplicate with the abp template.


12 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I will check it.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Could you share a project to reproduce? Thanks. shiwei.liang@volosoft.com

  • User Avatar
    0
    davidlbrenchley@gmail.com created

    Could you share a project to reproduce? Thanks. shiwei.liang@volosoft.com

    Couldn't see how to attach, so I created a public github for the project.

    .....................

  • User Avatar
    0
    davidlbrenchley@gmail.com created

    Could you share a project to reproduce? Thanks. shiwei.liang@volosoft.com

    Could you hold off looking at this. I'm getting different results now. Some strange results, but different. I will update or close the ticket within a day.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    ok,

  • User Avatar
    0
    davidlbrenchley@gmail.com created

    ok,

    Been able to narrow it down a bit further. Getting an error trying to use the string localizer now saying
    MauiBlazorCachedApplicationConfigurationClient should be initialized before using it.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    The MauiBlazorCachedApplicationConfigurationClient will initialize when the application starts.

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpAspNetCoreComponentsMauiBlazorModule.cs#L41

    I don't know the reason for the problem, How I reproduce the problem, could you provide the full steps? thanks.

  • User Avatar
    0
    davidlbrenchley@gmail.com created

    Hi,

    The MauiBlazorCachedApplicationConfigurationClient will initialize when the application starts.

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpAspNetCoreComponentsMauiBlazorModule.cs#L41

    I don't know the reason for the problem, How I reproduce the problem, could you provide the full steps? thanks.

    I had commented out the below which was giving me these other problems. I uncommented it, removing those issues, but brings the original problem back again of not being able to run in Release mode.

        app.Services.GetRequiredService<IAbpApplicationWithExternalServiceProvider>().Initialize(app.Services);
    

    I have verified again that the github repository I shared earlier in the ticket still has that problem and you can examine that.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    What's your steps?

  • User Avatar
    0
    davidlbrenchley@gmail.com created

    Hi,

    What's your steps?

    1, Ensure that the Maui project and not the MauiBlazor project is the startup project. 2. Ensure that the run button is selecting an Android emulator or a local android device. 3. Change from Debug mode to Release mode. 4. Run project. 5. When it runs you will see the splash screen for a second or two, and then it disappears and the app crashes.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    It looks like a problem with MAUI.

    You can try this:

    [ContentProperty(nameof(Text))]
    public class TranslateExtension : IMarkupExtension<BindingBase>
    {
        public string Text { get; set; } = string.Empty;
    
        public string? StringFormat { get; set; }
    
    
        public BindingBase ProvideValue(IServiceProvider serviceProvider)
        {
            var l = ServiceLocator.Current.GetRequiredService<LocalizationResourceManager>(); 
            
            var binding = new Binding
            {
                Mode = BindingMode.OneWay,
                Path = $"[{Text}]",
                Source = l,
                StringFormat = StringFormat
            };
            return binding;
        }
    
        object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) => ProvideValue(serviceProvider);
    }
    
    public static class ServiceLocator
    {
        public static IServiceProvider Current =>
    
    #if WINDOWS
                MauiWinUIApplication.Current.Services;
    #elif ANDROID
                MauiApplication.Current.Services;
    #elif IOS || MACCATALYST
                MauiUIApplicationDelegate.Current.Services;
    #else
                null;
    #endif
    }
    
  • User Avatar
    0
    davidlbrenchley@gmail.com created

    public static class ServiceLocator { public static IServiceProvider Current =>

    #if WINDOWS MauiWinUIApplication.Current.Services; #elif ANDROID MauiApplication.Current.Services; #elif IOS || MACCATALYST MauiUIApplicationDelegate.Current.Services; #else null; #endif }

    Yay, That worked! Thank you

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11