multithreadingjarxamarin.androidsqlite.net

How can I fix Java Bindings: UnsatisfiedLinkError?


I have been using Binding Project in xamarin for "kernal/io/serailport" java jar. The build process gives "serial_port.so" as shared object library. The C# code line invoking the functions present in serial_port.so is as:-

// This line calls java serialport class present in serial_port.so library refrenced in android project.
serialPort = new Kernal.io.SerialPort(device, Baudrate, 0);  

Now, the fun part is, the app runs well, but when I include 'sqlite-net-pcl' in android project for sqlite db access It gives exception mentioned below:-

Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lkernal/io/serialport Unhandled Exception  

This error occurs only when I add "sqlite-net-pcl" library in android project xamarin.

I guess the issue is related to threads. If "sqlite-net-pcl" is not included in android project then c# code calling method in binding project gets executed normally in main thread due to which no exception is raised and the app works fine, but, when "sqlite-net-pcl" is added in android project, I think some thing in sqlite pcl library makes calling of binding project method in another thread due to which above mentioned exception is raised.

Now, my question is how can I make c# code calling binding project method run in main thread or can I make slqite-net-pcl library to run on main thread which is not recommended.

If my guess is wrong, then what can be the cause of the exception raised and how can I tackle that.
Thankyou


Solution

  • Try using SQLite.NET dependency by building it yourself. ie. Add SQLite.NET project solution as the app dependency as opposed to using the nuget version.