Baseflow / MvxForms

Sample App with Xamarin.Forms and MvvmCross

Home Page:https://baseflow.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App Crash

situssoft opened this issue · comments

Hi,

I've just cloned this repo and built and run locally on both android simulator and a google pixel. In both cases the app starts and shows the splash screen then after a short delay crashes. I have not modified the code.

This is my first attempt to use Mvvmcross and Xamarin forms. All I get from the debugger is the following rather unhelpful exception.

Unhandled Exception:

System.ArgumentNullException: Value cannot be null.
Parameter name: source occurred

Can you advise how I might progress to a working solution?

@situssoft, did you ever resolve your issue with this? I am running into the same thing.

Same thing here.

No, I didn't find a fix and I was unable to build the code from source control (which is a pet hate) so I've moved my project to Prism.

Same problem here. Any suggestions?

I discovered the solution for this problem, remove the class Setup and SplashScreen and change the MainActivity for like this:

[Activity(Label` = "Sample", Icon = "@mipmap/icon", Theme = "@style/AppTheme",
              ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
              MainLauncher = true, LaunchMode = LaunchMode.SingleTask)]
    public class MainActivity : MvxFormsAppCompatActivity<MvxFormsAndroidSetup<CoreApp, App>, CoreApp, App>
    {
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;
            base.OnCreate(bundle);
        }
    }

More details in TipCalc Sample

Unfortunately, this is quite often thing with MvvmCross these days, when it just doesn't work out-of-box. So, lots of devs just choose other frameworks.

@rafaelnicolett, this is still not ideal solution as it considers no splash screen, which is barely acceptable for most of apps.

After some investigation I've found correct way to make it work (quite weird why there is no docs about that anywhere) (hello wasted 4 hours of my time):

        public class SplashScreen : MvxFormsSplashScreenAppCompatActivity<Setup, CoreApp, App>

The only trick here is setting Theme = "@style/MainTheme" to support AppCompat one, but all that is just up to the dev how to define it then...

@agat366 Great observation, I know that my solution it's bad, but it's work for hour.
Thank you for shared you solution with us. 👌

@agat366 Great, it's work now perfect. Thank you 😊