Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You must call EnsureLoaded on the File plugin before using the DownloadCache

Tags:

mvvmcross

I've updated to MvvmCross version 4.2.1 from version 4.2.0 via NuGet and now the Android project crashes during startup. An MvxException is thrown during the splash screen with the message:

MvvmCross.Platform.Exceptions.MvxException: You must call EnsureLoaded on the File plugin before using the DownloadCache

I actually am calling this method in MvxAppCompatSetup.InitializeLastChance override. This worked well for me with version 4.2.0, but now the code doesn't even hit InitializeLastChance when running version 4.2.1.

protected override void InitializeLastChance()
{
    base.InitializeLastChance();
    MvvmCross.Plugins.File.PluginLoader.Instance.EnsureLoaded();
    MvvmCross.Plugins.DownloadCache.PluginLoader.Instance.EnsureLoaded();
}

I can't move the EnsureLoaded calls to InitializeFirstChance because there I'll get an exception because plugins haven't yet been initialized

Failed to resolve type MvvmCross.Platform.Plugins.IMvxPluginManager

The MvxSetup.InitializePluginFramework appears to be throwing this exception when InitializePluginFramework is called.

NuGet displayed error messages for each plugin I have installed during the update:

[Failure] Could not file file '...\Project.Droid\Bootstap\XXXBootstrap.cs'

The files are definitely there and the package installs without reporting an error.

What is the correct way to handle this problem?

like image 731
Trevor Balcom Avatar asked Jul 05 '16 20:07

Trevor Balcom


1 Answers

Try to remove DownloadCachePluginBootstrap.cs and FilePluginBootstrap.cs just leave manual setup inside InitializeLastChance(). It seems that there is a problem with loading order.

like image 126
Piotr Bialic Avatar answered Sep 16 '22 15:09

Piotr Bialic