Search code examples
dllxamarin.androidvisual-studio-2017mvvmcross

Xamarin MvvmCross Visual Studio 2017: The type or namespace name 'MvxFragmentsPresenter' could not be found


Visual Studio 2017 ce, xamarin proj, MvvmCross 5.6.3
Under MyApp.Mobile.Android I have Setup.cs file:

public class Setup: MvxAndroidSetup
    {

        //ctor, CreateApp, CreateDebugTrace go here

        protected override IMvxAndroidViewPresenter CreateViewPresenter()
        {
            var mvxFragmentsPresenter =
                new MvxFragmentsPresenter(AndroidViewAssemblies); //error here
            Mvx.RegisterSingleton<IMvxAndroidViewPresenter>(mvxFragmentsPresenter);
            return mvxFragmentsPresenter;
        }
}

I receive an error: The type or namespace name 'MvxFragmentsPresenter' could not be found.

The code is from a tutorial for MvvmCross ver. 4.1.1. Documentation doesn't contain any information about upgrade from v4 to v5 ( https://www.mvvmcross.com/documentation/upgrading/upgrade-to-mvvmcross-50 ) related to it.

Also I downloaded several MvvmCross packages via nuget, but unfortunately there were no implementation of MvxFragmentsPresenter. For MvvmCross v4 class MvxFragmentsPresenter was defined in assembly MvvmCross.Droid.Shared. Currently there is no such package on nuget.


Solution

  • MvxFragmentsPresenter was removed in MvvmCross 5.2.0 as part of the rewrite of the Android presenters to support attribute rooting similar to the iOS attribute rooting available since 5.0.0.

    You can checkout the blog post related to the release of 5.2.0. Additionally, the Android presenter documentation may be of assistance.

    MvvmCross 5.2.0+ no longer differentiates presenters based on the ability to show fragments (MvxFragmentsPresenter or MvxAndroidPresenter). Instead it now offers either

    • MvxAndroidViewPresenter - Android SDK activities and fragments
    • MvxAppCompatViewPresenter - Android Support Libraries activities and fragments