Home > Software engineering >  Application get stuck at SplashScreen after MvvmCross upgrade to 8.x
Application get stuck at SplashScreen after MvvmCross upgrade to 8.x

Time:10-26

I upgraded all MvvmCross libraries from 7.1.2 to 8.0.0. According to "Upgrade from 7 to 8" tutorial from mvvmcross documentation, I have implemented necessary changes (override CreateLogProvider and CreateLogFactory methods and added iocProvider as parameter to InitializeFirstChance, InitializeLastChance, InitializeNavigationService and CreateApp):

public class Setup : MvxAndroidSetup
    {
        protected override IMvxAndroidViewPresenter CreateViewPresenter() => new HistoryViewPresenter(ViewAssemblies);

        protected override void InitializeFirstChance(IMvxIoCProvider iocProvider)
        {
            base.InitializeFirstChance(iocProvider);
            //Things are done here
        }

        protected override void InitializeLastChance(IMvxIoCProvider iocProvider)
        {
            base.InitializeLastChance(iocProvider);
            //Things are done here
        }

        protected override IMvxNavigationService InitializeNavigationService(IMvxIoCProvider iocProvider)
        {
            var loader = CreateViewModelLoader(iocProvider);
            Mvx.IoCProvider.RegisterSingleton<IMvxViewModelLoader>(loader);
            InitializeViewDispatcher(iocProvider);
            var dispatcher = CreateViewDispatcher();
            Mvx.IoCProvider.RegisterSingleton(dispatcher);
            var navigationService = new DeepNavigationService(null, loader, dispatcher, iocProvider);
            Mvx.IoCProvider.RegisterSingleton<IMvxNavigationService>(navigationService);
            return navigationService;
        }

       //Another things are done here

        protected override IMvxApplication CreateApp(IMvxIoCProvider iocProvider)
        {
            return new App();
        }

        protected override ILoggerProvider CreateLogProvider()
        {
            return new SerilogLoggerProvider();
        }

        protected override ILoggerFactory CreateLogFactory()
        {
            Serilog.Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .CreateLogger();

            return new SerilogLoggerFactory();
        }
    }

I have also created custom app start in Core project and set this class RegisterCustomAppStart:

public class AppStart : MvxAppStart
    {
        public AppStart(IMvxApplication application, IMvxNavigationService navigationService) : base(application, navigationService) { }

        protected override Task NavigateToFirstViewModel(object hint = null)
        {
            return NavigationService.Navigate<StartupViewModel>();
        }
    }

public class App : MvxApplication
    {
        public override void Initialize()
        {
            //Services and Singletons are registered here.
            RegisterCustomAppStart<AppStart>();
        }
    }

And here is the issue- when I run app, my app get stuck in SplashScreen. Did anyone face similar issue? On the previous version, everything was fine. I would be grateful for some advice how to fix that

CodePudding user response:

I resolved this issue - I changed line:

var dispatcher = CreateViewDispatcher();

For:

var dispatcher = Mvx.IoCProvider.Resolve<IMvxViewDispatcher>();

And it works.

  • Related