System.DllNotFoundException:/system/lib/libsqlite.so- Xamarin形式 [英] System.DllNotFoundException: /system/lib/libsqlite.so- Xamarin Forms

查看:254
本文介绍了System.DllNotFoundException:/system/lib/libsqlite.so- Xamarin形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在xamarin表单项目中面临SQLite问题.但是SQLiteConnection我试图在Android平台上实例化那里出现异常.

I am facing SQLite issue in xamarin forms project. However SQLiteConnection I am trying to instantiating in Android platform there getting exception.

在android&中使用的库iOS项目

Libraries using in android & iOS project

  • SQLite.Net-PCL 3.1.1
  • SQLite.Net.Core-PCL 3.1.1

清单文件目标版本

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />

AndroidSQLite.cs文件

AndroidSQLite.cs file

using SQLite;
using SQLite.Net;
using System.IO;
namespace XamarinTestList.Droid.Implementations
{
public class AndroidSQLite : ISQLite
{
    public SQLiteConnection GetConnection()
    {
        string documentPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
        var path = Path.Combine(documentPath, DatabaseHelper.DbFileName); //DbFileName="Contacts.db"
        var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
        string dpPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3");
        var conn= new SQLiteConnection(plat, dpPath);
        return conn;
    }
}
}

 var conn= new SQLiteConnection(plat, dpPath);

我已经在解决方案级别上安装了上述库,但是在共享项目中,没有可用于安装Nuget软件包的选项.共享项目的屏幕截图

I have installed above libraries on solution level but in shared project, there is no option available to install Nuget packages. Shared project screen shot

在本文之后,您将学习使用xamarin的SQLite. xamarin形式-mvvm-sqlite-sample

Following this article to learn SQLite with xamarin xamarin forms-mvvm-sqlite-sample.

下面是完全例外

{System.DllNotFoundException:/system/lib/libsqlite.so at(包装 本地管理) SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroidInternal.sqlite3_open_v2(byte [],intptr&,int,intptr) 在SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroid.Open (System.Byte []文件名,SQLite.Net.Interop.IDbHandle& db, System.Int32标志,System.IntPtr zvfs)[0x00000]在 < 8dbf6ff85082469fb9d4dfaa9eae6b69>:0在 SQLite.Net.SQLiteConnection..ctor(SQLite.Net.Interop.ISQLitePlatform sqlitePlatform,System.String databasePath, SQLite.Net.Interop.SQLiteOpenFlags openFlags,System.Boolean storeDateTimeAsTicks,SQLite.Net.IBlobSerializer序列化器, System.Collections.Generic.IDictionary 2[TKey,TValue] tableMappings, System.Collections.Generic.IDictionary 2 [TKey,TValue] extraTypeMappings,SQLite.Net.IContractResolver解析器)[0x000a2]在 < 8f2bb39aeff94a30a8628064be9c7efe>:0在 SQLite.Net.SQLiteConnection..ctor(SQLite.Net.Interop.ISQLitePlatform sqlitePlatform,System.String databasePath,System.Boolean storeDateTimeAsTicks,SQLite.Net.IBlobSerializer序列化器, System.Collections.Generic.IDictionary 2[TKey,TValue] tableMappings, System.Collections.Generic.IDictionary 2 [TKey,TValue] extraTypeMappings,SQLite.Net.IContractResolver解析器)[0x00000]在 < 8f2bb39aeff94a30a8628064be9c7efe>:0

{System.DllNotFoundException: /system/lib/libsqlite.so at (wrapper managed-to-native) SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroidInternal.sqlite3_open_v2(byte[],intptr&,int,intptr) at SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroid.Open (System.Byte[] filename, SQLite.Net.Interop.IDbHandle& db, System.Int32 flags, System.IntPtr zvfs) [0x00000] in <8dbf6ff85082469fb9d4dfaa9eae6b69>:0 at SQLite.Net.SQLiteConnection..ctor (SQLite.Net.Interop.ISQLitePlatform sqlitePlatform, System.String databasePath, SQLite.Net.Interop.SQLiteOpenFlags openFlags, System.Boolean storeDateTimeAsTicks, SQLite.Net.IBlobSerializer serializer, System.Collections.Generic.IDictionary2[TKey,TValue] tableMappings, System.Collections.Generic.IDictionary2[TKey,TValue] extraTypeMappings, SQLite.Net.IContractResolver resolver) [0x000a2] in <8f2bb39aeff94a30a8628064be9c7efe>:0 at SQLite.Net.SQLiteConnection..ctor (SQLite.Net.Interop.ISQLitePlatform sqlitePlatform, System.String databasePath, System.Boolean storeDateTimeAsTicks, SQLite.Net.IBlobSerializer serializer, System.Collections.Generic.IDictionary2[TKey,TValue] tableMappings, System.Collections.Generic.IDictionary2[TKey,TValue] extraTypeMappings, SQLite.Net.IContractResolver resolver) [0x00000] in <8f2bb39aeff94a30a8628064be9c7efe>:0

推荐答案

SQLite.您使用的Net-PCL nuget不再由其作者维护.您需要切换到其他类似的软件包 sqlite-net-pcl

The SQLite.Net-PCL nuget you used is no longer being maintained by it's author. You need to switch to other similar package sqlite-net-pcl

首先从所有项目中删除现有的SQLite.Net-PCL nuget,然后安装我上面提到的那个.从所有文件中删除所有旧的与SQLite相关的引用.

First remove the existing SQLite.Net-PCL nuget from all projects and install the one I mentioned above. Remove all old SQLite related references from all files.

您需要在与连接相关的SQLite依赖项服务类中进行一些更改.然后,您可以调整其他与SQLite相关的代码.通过为新的nuget包添加适当的using语句来解析引用.

You need to make some changes in SQLite connection related dependency service classes. Then you may adjust some other code which relates to SQLite. Resolve the references by adding appropriate using statements for the new nuget package.

我遇到了同样的错误,我通过切换到上述nuget包解决了该问题.

I got the same error and I solved it by switching to above nuget package.

注意:新的nuget程序包尚没有InsertOrReplaceAll方法.因此,如果您从以前的nuget中使用了此方法,那么对于新的nuget,您需要创建一个

NOTE : The new nuget package does not have InsertOrReplaceAll method yet. So If you have used this method from previous nuget, then for the new nuget, you need to create an InsertOrReplaceAll extension method.

编辑:要获取SQLiteConnection,

EDIT: To get the SQLiteConnection:

public SQLiteConnection GetConnection()
{
    return new SQLiteConnection(dpPath, false);
}

无需在新的Nuget中传递平台.如果您不想将DateTime存储为Ticks,请通过false.

There is no need to pass the platform in this new nuget. Pass false if you don't want to store DateTime as Ticks.

这篇关于System.DllNotFoundException:/system/lib/libsqlite.so- Xamarin形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆