Thursday, July 16, 2015

plugin not registered for type Cirrious.MvvmCross.Community.Plugins.Sqlite - Unified API

Problem:



I just successfully published the app to the iTunes store.  I had the application written and ready to publish when the wonderful Application Loader refused to load my app to the store!!  Why, because
it was not built to support the Unified API.  Easy fix just use the Xamarin upgrade to Unified Api and voila!  But Unified API is not compatible with MVVMCross SQLite Plugin (v 3.2.2)

Wait, not so fast.  I immediately had problems with the SQLite libraries for MVVMCross. 
This caused me about a week of pain working through all the interdepencies.  I was able to get the latest source code from https://github.com/MvvmCross/MvvmCross-SQLite/issues/39.  Then I built out the bits for support of my project.  I was able to compile and run the app.  It would crash each time I ran and attempted to load the screen which loaded  the sql lite plugin!!!

Error:
plugin not registered for type Cirrious.MvvmCross.Community.Plugins.Sqlite

I wracked my brain as to why the ui failed each time on the sqlite load.  I finally reread the api documentation on the MVVMCross wiki.  It finally hit me when I came across this added requirement for the iOS platform plugin. 



Solution:

You must include a second argument in the bootstrap action for the sqllite plugin.  The bootstrap needs the second argument in the interface constructor for iOS.  If you fail to include it then the path to the Touch plugin then the runtime will not load the plugin and will give you the error.

This is not a problem in Droid or Windows Phone builds.

 
using Cirrious.CrossCore.Plugins; 
using Cirrious.MvvmCross.Community.Plugins.Sqlite; 
using Cirrious.MvvmCross.Community.Plugins.Sqlite.Touch; 


public class SqlitePluginBootstrap 
: MvxLoaderPluginBootstrapAction<Plugins.Sqlite.PluginLoader, Plugins.Sqlite.Touch.Plugin> 
{ }




Source:
  1. https://github.com/MvvmCross/MvvmCross/wiki
  2.  https://github.com/MvvmCross/MvvmCross-SQLite/issues/39
  3. http://stackoverflow.com/questions/30648697/mvvmcross-community-plugin-for-sqlite-with-unified-api 
  4.  http://blog.alectucker.com/post/2015/01/19/sqlite-error-with-xamarinios-unified-api.aspx
  5.  https://bitbucket.org/twincoders/sqlite-net-extensions

No comments:

Post a Comment