Efeyabel
Efeyabel

Reputation: 508

Xamarin Sqlite-pcl library problems

I try to make a app and work with sqlite-pcl and got the following error when my app starts;

DllImport attempting to load: 'e_sqlite3'.
DllImport error loading library '/storage/emulated/0/Android/data/appTecnicos.appTecnicos/files/.__override__/libe_sqlite3': 'dlopen failed: library "/data/app/appTecnicos.appTecnicos-1/lib/x86//storage/emulated/0/Android/data/appTecnicos.appTecnicos/files/.__override__/libe_sqlite3" not found'.
DllImport error loading library '/storage/emulated/0/Android/data/appTecnicos.appTecnicos/files/.__override__/libe_sqlite3.so': 'dlopen failed: library "/data/app/appTecnicos.appTecnicos-1/lib/x86//storage/emulated/0/Android/data/appTecnicos.appTecnicos/files/.__override__/libe_sqlite3.so" not found'.
DllImport error loading library '/system/lib/libe_sqlite3': 'dlopen failed: library "/data/app/appTecnicos.appTecnicos-1/lib/x86//system/lib/libe_sqlite3" not found'.
DllImport error loading library '/system/lib/libe_sqlite3.so': 'dlopen failed: library "/data/app/appTecnicos.appTecnicos-1/lib/x86//system/lib/libe_sqlite3.so" not found'.
DllImport error loading library 'libe_sqlite3': 'dlopen failed: library "/data/app/appTecnicos.appTecnicos-1/lib/x86/libe_sqlite3" not found'.
DllImport loaded library 'libe_sqlite3.so'.
DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so').
Searching for 'sqlite3_libversion_number'.
An unhandled exception occured.

I installed the nuget package in both solutions, portable and droid. I installed the Sqlite component in droid project.

I cleaned the build and recompiled but it returned the same error.

EDIT:

I found this on my Compiler debug;

Loaded assembly: /storage/emulated/0/Android/data/appTecnicos.appTecnicos/files/.__override__/SQLitePCLRaw.lib.e_sqlite3.dll

Its seems like the e_sqlite3.dll its already on the proyect.

Thanks in advance

Upvotes: 0

Views: 1460

Answers (3)

thomiel
thomiel

Reputation: 2975

The "DllImport error loading library '.../.override/libe_sqlite3'" message has been misleading to me as well. The debug output was just coinciding with the actual exception that froze my app.

For me, it was using a relative path in the new SQLiteConnection() -- which was working perfectly fine before with the UWP version. After I changed it to use an absolute path, it also worked on Android:

var dbpath = Path.Combine(System.Environment.GetFolderPath(
    System.Environment.SpecialFolder.LocalApplicationData), "myData.sqlite");
db = new SQLiteConnection(dbpath, false);

Upvotes: 1

Efeyabel
Efeyabel

Reputation: 508

I found my error. I got a class like;

public class StaticsValues
{
    [...]
    public static string FOLDERPATH;
    public static string DBPATH;
    public static BD.BDManager BDMANAGER = new BD.BDManager;
}

And the object BDManager start in the solution before my DROID project compiled. I change to:

public class StaticsValues
{
    [...]
    public static string FOLDERPATH;
    public static string DBPATH;
    public static BD.BDManager BDMANAGER ;
}

And start BD.Manager in App.cs and now works.

Upvotes: 0

Zroq
Zroq

Reputation: 8402

I think that the package has not been correctly installed on your starting app. Remove sqlite-pcl, clean, rebuild & install it to your starting app and droid project. Also check your references to see if its really there.

Upvotes: 0

Related Questions