无法在 Xamarin 中安装 SQLite-Net-pcl

Impossible to install SQLite-Net-pcl in Xamarin

我正在尝试将我的项目从 SQLite.Net-PCL 转换为 sqlite-net-pcl(最新的稳定版本;1.3.1),如 Xamarin's working with databases,但当我安装它时,它必须安装 40 个包(或左右),如下所列

Microsoft.NETCore.Platforms 1.0.1
Microsoft.NETCore.Targets 1.0.1
runtime.native.System   4.0.0
SQLitePCLRaw.core 1.1.2
SQLitePCLRaw.bundle_green 1.1.2
System.Collections 4.0.11
System.Collections.Concurrent 4.0.12
System.Diagnostics.Debug 4.0.11
System.Diagnostics.Tools 4.0.1
System.Diagnostics.Tracing 4.1.0
System.Globalization 4.0.11
System.IO 4.1.0
System.IO.Compression 4.1.0
System.Linq 4.1.0
System.Linq.Expressions 4.1.0
System.Net.Http 4.1.0
System.Net.Primitives 4.0.11
System.ObjectModel 4.0.12
System.Reflection 4.1.0
System.Reflection.Extensions 4.0.1
System.Reflection.Primitives 4.0.1
System.Resources.ResourceManager 4.0.1
System.Runtime 4.1.0
System.Runtime.Extensions 4.1.0
System.Runtime.InteropServices 4.1.0
System.Runtime.Numerics 4.0.1
System.Text.Encoding 4.0.11
System.Text.Encoding.Extensions 4.0.11
System.Text.RegularExpressions 4.1.0
System.Threading 4.0.11
System.Runtime.InteropServices.RuntimeInformation 4.0.0
System.Threading.Tasks 4.0.11
System.Xml.ReaderWriter 4.0.11
System.Xml.XDocument 4.0.11
NETStandard.Library 1.6.0
sqlite-net-pcl 1.3.1

我知道它需要一些包,但对我来说似乎有很多包。 我正在使用 Xamarin.Forms 版本 2.3.3.180(最新稳定版)

如果我继续安装,就会出现这样的错误

Could not install package 'System.Runtime.InteropServices.RuntimeInformation 4.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

如何安装 sqlite-net-pcl,以便我可以在 Android N 上继续使用 SQLite?

现在我有这些目标

.NET Framework 4.5
Windows 8
ASP.NET Core 1.0 (I do not know why this is set)
Windows Phone 8.1 (I am not using this, but it says I have to reinstall all Nuget packages, if I want to remove it)
Xamarin.Android
Xamarin.iOS
Xamarin.iOS (Classic)
Xamarin.Mac (neither using this)

我是否必须删除我不使用的目标并重新安装所有 Nuget 包?

我正在使用这些 NuGet 包

Acr.UserDialogs
ExifLib.PCL
Microsoft.NETCore.UniversalWindowsPlatform
MR.Gestures
Newtonsoft.Json
Xam.Plugin.Media
Xam.Plugins.Settings
Xamarin.Forms
Xamarin.Insights
Xamarin.UITest
XLabs.Forms
ZXing.Net.Mobile.Forms

恐怕你将不得不按照你说的去做。我遇到了类似的问题(幸运的是这是一个新项目),然后我别无选择。您将必须删除每个 nuget 包,更改目标以删除导致此错误的那个,然后重新安装所有包。 我建议您一个一个地删除目标并尝试安装 sqlite。您将能够隔离导致错误的目标。

您已经安装了 .NetStandard 版本

Release Notes v1.3.1:

Switch to .NET Standard

如你所见 NETStandard.Library 1.6.0 现在作为一个包添加。

我会删除 sqlite-net-pcl 1.3.1 和它为 .NetStandard 安装的其他包,然后使用 v1.2.1 因为它仍然有 Android N 的修复,因为它从 here

添加了 bundle_green

v1.2.1: Update .raw to bundle_green 1.1.0

您可以阅读有关此修复的更多信息 here

我已将该库移植到纯 .NET 标准。我已将其缩减为一个适用于所有平台的库:android、iOS、uwp 等,但我删除了 orm 功能。 https://github.com/MelbourneDeveloper/SQLite.Net.Standard

NuGet:SQLite.Net.Standard

我遇到了同样的问题。我通过首先安装 'System.Runtime.InteropServices.RuntimeInformation 4.0.0' 然后安装 SQlite-pcl 包解决了我的问题。