System.MissingMethodException:未找到方法“MvvmCross.Droid.Views.MvxAndroidViewPresenter..ctor" [英] System.MissingMethodException: Method 'MvvmCross.Droid.Views.MvxAndroidViewPresenter..ctor' not found
问题描述
我创建了设置:MvxAndroidSetup
I created Setup : MvxAndroidSetup
public class Setup : MvxAndroidSetup
{
public Setup(Context applicationContext)
: base(applicationContext)
{
}
protected override IMvxApplication CreateApp()
{
return new App();
}
protected override IEnumerable<Assembly> AndroidViewAssemblies =>
new List<Assembly>(base.AndroidViewAssemblies)
{
typeof(Android.Support.Design.Widget.NavigationView).Assembly,
typeof(Android.Support.Design.Widget.FloatingActionButton).Assembly,
typeof(Android.Support.V7.Widget.Toolbar).Assembly,
typeof(Android.Support.V4.Widget.DrawerLayout).Assembly,
typeof(Android.Support.V4.View.ViewPager).Assembly,
typeof(MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerView).Assembly
};
/// <summary>
/// This is very important to override. The default view presenter does not know how to show fragments!
/// </summary>
protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
var mvxFragmentsPresenter = new MvxFragmentsPresenter(AndroidViewAssemblies);
Mvx.RegisterSingleton<IMvxAndroidViewPresenter>(mvxFragmentsPresenter);
return mvxFragmentsPresenter;
}
}
我使用的是 mvvmscross 版本 5.2.1我在行代码 var mvxFragmentsPresenter = new MvxFragmentsPresenter(AndroidViewAssemblies); 中有问题.运行项目时mac 中的 Visual Studio 2017 通知:
I using mvvmscross Version 5.2.1 I have issue in line code var mvxFragmentsPresenter = new MvxFragmentsPresenter(AndroidViewAssemblies);. when run project Visual studio 2017 in mac notify that:
System.MissingMethodException: Method 'MvvmCross.Droid.Views.MvxAndroidViewPresenter..ctor' not found.
at VietOrder.Droid.Setup.CreateViewPresenter () [0x00001] in /Volumes/Data/Dev/VietOrder/Xamarin/VietOrder/VietOrder.Droid/Setup.cs:46
at MvvmCross.Droid.Platform.MvxAndroidSetup.CreateViewDispatcher () [0x00000] in C:\projects\mvvmcross\MvvmCross\Droid\Droid\Platform\MvxAndroidSetup.cs:124
at MvvmCross.Core.Platform.MvxSetup.InitializeViewDispatcher () [0x00000] in C:\projects\mvvmcross\MvvmCross\Core\Core\Platform\MvxSetup.cs:260
at MvvmCross.Core.Platform.MvxSetup.InitializeSecondary () [0x000f8] in C:\projects\mvvmcross\MvvmCross\Core\Core\Platform\MvxSetup.cs:91
at MvvmCross.Droid.Platform.MvxAndroidSetupSingleton.<InitializeFromSplashScreen>b__7_0 (System.Object ignored) [0x00000] in C:\projects\mvvmcross\MvvmCross\Droid\Droid\Platform\MvxAndroidSetupSingleton.cs:92
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x00007] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
谢谢!
推荐答案
我想我已经解决了,但是从 4.4.0 版本升级到最新的 MvvmCross 版本 (5.3.1) 的漫长旅程已经走到了尾声.我将确定完成升级所需的步骤.应该注意的是,在此之前,我已将所有 Xamarin 和其他包更新为最新和最好的,并确保项目编译和运行.此外,我将 Xamarin 本身更新到 4.7.10.22,这带来了对 Android 8.0 的支持(我还没有 iOS 前端).这是我更新到 MvvmCross 5.3.1 所经历的步骤:
I think I solved it but its been at the tail end of a long journey to upgrade to the latest MvvmCross version (5.3.1) from version 4.4.0. I will identify the steps I needed to go through the upgrade. It should be noted that prior to this I have updated all Xamarin and other packages to the latest and greatest and ensured the project compiles and runs. In addition I updated Xamarin itself to 4.7.10.22 which brought support for Android 8.0 (I don't have an iOS front-end yet). Here the steps I went through to update to MvvmCross 5.3.1:
- 将所有 MvvmCross 包升级到 5.3.1
- 删除 MvvmCross.Droid.Shared (4.4.0)
- 添加 MvvmCross.Droid.Support.Core.UI (5.3.1)
- 添加 MvvmCross.Droid.Support.Core.Utils (5.3.1)
- 添加 MvvmCross.Droid.Support.Fragment (5.3.1)
现在回答您的问题,我将我的 Setup 类从 MvxAppCompatSetup 更改为子类.对 MvxAppCompatSetup 的调用更改为简单创建一个新的 MvxAppCompatViewPresenter()(见下文)并移除 MvvmCross.Droid.Shared.Presenter 的导入:
Now to answer your questions, I changed my Setup class to subclass from MvxAppCompatSetup. Call to the MvxAppCompatSetup changed to a simple creation of a new MvxAppCompatViewPresenter() (see below) plus removal of import of MvvmCross.Droid.Shared.Presenter:
protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
return new MvxAppCompatViewPresenter(AndroidViewAssemblies);
}
另外,由于我使用了一些 Fragment,我需要将它们的 Attributes 从 MvxFragment 更改为 MvxFragmentPresentation.最后的更改是将我的主要活动从子类 MvxCachingFragmentCompatActivity 更改为子类 MvxAppCompatActivity.所有这些都对我有用,希望能帮到你.
In addition, since I was using some Fragments, I needed to change the Attributes on them from MvxFragment to MvxFragmentPresentation. Last change was to change my main Activity from sub-classing MvxCachingFragmentCompatActivity to sub-classing MvxAppCompatActivity. All this did the trick for me and hopefully will help you.
附言我仍然需要更改导航以符合新的 NavigationService.
P.S. I still have to change navigation to conform to the new NavigationService.
这篇关于System.MissingMethodException:未找到方法“MvvmCross.Droid.Views.MvxAndroidViewPresenter..ctor"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!