Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MvvmCross.Exceptions.MvxException: Failed to create setup instance

I'm upgrading from MvvMCross 5.7 to 6.0.0.

When I try to run the app, it shows the splash screen and just after that, vs2017 gives me the following error:

MvvmCross.Exceptions.MvxException: Failed to create setup instance

The error always is in the same line, no matter which file I set as mainlauncher.

Example:

using Android.App;
using Android.OS;
using MvvmCross.Droid.Support.V7.AppCompat;
using MvvmCross.Platforms.Android.Views;

namespace ClaveiSGApp.Droid.Views
{
    [Activity(Label = "App", MainLauncher = true)]
    public class MainView : MvxAppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.MainView);
        }
    }
}

The error always is in base.OnCreate(bundle);

Do you have any ideas?

(Let me know if you need more info/code about something)

like image 228
Brugui Avatar asked Jun 19 '26 00:06

Brugui


1 Answers

From the error you're getting, it looks like something bad is happening in CreateSetup method in MvxSetupSingleton (GitHub). I'm guessing here a bit, but I would assume that there's something wrong with how the RegisterSetupType<TMvxSetup> is being called (or it's not being called at all) - you can find this method in MvxSetup (GitHub). Tracking down where the registration happens, it gave me two possible places: MvxSplashScreenActivity<TMvxAndroidSetup, TApplication> and MvxAndroidApplication<TMvxAndroidSetup, TApplication>.

Going forward with this thinking, and assuming you do use SplashScreen in your app. I would suggest updating your SplashScreen activity to inherit from MvxSplashScreenActivity<TMvxAndroidSetup, TApplication> and check if that helps - you would also need to make your SplashScreen is MainLauncher. Your code could look like this:

[Activity(Label = "FirstDemo.Forms.Splash", Theme = "@style/MainTheme",  MainLauncher = true, NoHistory = true)]
public class SplashScreen : MvxFormsSplashScreenAppCompatActivity<MvxFormsAndroidSetup<Core.App, App>, Core.App, App>
{
    public SplashScreen()
         : base(Resource.Layout.SplashScreen)
    {
    }

    protected override void RunAppStart(Bundle bundle)
    {
        StartActivity(typeof(MainActivity));
        base.RunAppStart(bundle);
    }
}

If the above is not clear, check out blog post by Nick Randolph (a contributor to MvvmCross), that writes about setting up a brand new project with MvvmCross v6. I know you're upgrading - so it's not the same, but you can at least check if you have made all the changes that are required to run the app. Here's his GitHub repo, with the sample code that I pasted in

like image 162
Mikolaj Kieres Avatar answered Jun 20 '26 14:06

Mikolaj Kieres



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!