Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MvvmCross vnext: merge plugins with monodroid

I'm trying to merge plugins library projects into a single one (for example, Location + PhoneCallTask). It works perfectly with wp7, but I get an unhandled exception with monodroid:

Could not load file or assembly 'Cirrious.MvvmCross.Plugins.Location.Droid.dll'

Of course, the location plugin is referenced in 'Cirrious.MvvmCross.Plugins.Droid.dll', the merged library.

Is there a way to point to the merged library path?

like image 209
Alphapage Avatar asked Oct 17 '12 09:10

Alphapage


1 Answers

Having considered your question more fully...

I'm still not entirely sure what a merge plugin is, but I think the problem you are seeing must be down to the way that MvvmCross-MonoDroid uses file conventions to load plugins while all the other platforms force the user to provide explicit factory methods for each plugin.

The reason for this difference is because the file conventions are (IMO) the nicest way of doing this... but all the other platforms put security and/or compilation issues in the way which meant that alternative mechanisms had to be used...

The easiest thing for you to do is probably to switch the setup of your MonoDroid app to use the loader conventions too.

To do this:

  • in Setup.cs override CreatePluginManager() to:

    protected override IMvxPluginManager CreatePluginManager()
    {
        var toReturn = new MvxLoaderBasedPluginManager();
        var registry = new MvxLoaderPluginRegistry(".Droid", toReturn.Loaders);
        AddPluginsLoaders(registry);
        return toReturn;
    }
    

and then provide a AddPluginsLoaders() implementation like:

    protected virtual void AddPluginsLoaders(Cirrious.MvvmCross.Platform.MvxLoaderPluginRegistry loaders)
    {
        loaders.AddConventionalPlugin<Cirrious.MvvmCross.Plugins.Visibility.Droid.Plugin>();
        loaders.AddConventionalPlugin<Cirrious.MvvmCross.Plugins.Location.Droid.Plugin>();
        loaders.AddConventionalPlugin<Cirrious.MvvmCross.Plugins.Phone.Droid.Plugin>();
        loaders.AddConventionalPlugin<AlphaPage.MvvmCross.Plugins.Mega.Droid.Plugin>();
        // etc
    }
like image 198
Stuart Avatar answered Nov 03 '22 02:11

Stuart