You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[tests] enable sqlite-net-pcl test in .NET 6 (#5366)
Fixes: #5319
Context: ericsink/SQLitePCL.raw#383
This test was originally failing in 6e3e383 with:
android.runtime.JavaProxyThrowable: System.TypeInitializationException: The type initializer for 'SQLite.SQLiteConnection' threw an exception.
---> System.DllNotFoundException: e_sqlite3
at System.Runtime.InteropServices.NativeLibrary.LoadLibraryByName(String libraryName, Assembly assembly, Nullable`1 searchPath, Boolean throwOnError)
at System.Runtime.InteropServices.NativeLibrary.Load(String libraryName, Assembly assembly, Nullable`1 searchPath)
at SQLitePCL.NativeLibrary.Load(String libraryName, Assembly assy, Int32 flags)
at SQLitePCL.Batteries_V2.MakeDynamic(String name, Int32 flags)
at SQLitePCL.Batteries_V2.DoDynamic_cdecl(String name, Int32 flags)
at SQLitePCL.Batteries_V2.Init()
at SQLite.SQLiteConnection..cctor()
The problem being one of the transitive dependencies of
`sqlite-net-pcl`: [`SQLitePCLRaw.bundle_green`][0].
`SQLitePCLRaw.bundle_green` pulls in even more packages:
.NETCoreApp 3.1
SQLitePCLRaw.core (>= 2.0.4)
SQLitePCLRaw.lib.e_sqlite3 (>= 2.0.4)
SQLitePCLRaw.provider.dynamic_cdecl (>= 2.0.4)
MonoAndroid 8.0
SQLitePCLRaw.core (>= 2.0.4)
SQLitePCLRaw.lib.e_sqlite3.android (>= 2.0.4)
SQLitePCLRaw.provider.e_sqlite3 (>= 2.0.4)
`SQLitePCLRaw.lib.e_sqlite3.android` contains the `libe_sqlite3.so`
native library for Android. In .NET 6, NuGet is preferring the
`.NETCoreApp 3.1` packages over the `MonoAndroid 8.0` ones.
This means that the `MonoAndroid 8.0` package contents aren't
included in the `.apk`, resulting in the `DllNotFoundException`.
To manually workaround the problem we can add an explicit
`@(PackageReference)` to [`SQLitePCLRaw.lib.e_sqlite3.android`][1]
into the Android head project:
<PackageReference Include="SQLitePCLRaw.lib.e_sqlite3.android" Version="2.0.4" />
Then the test works as expected.
[Eventually, `SQLitePCLRaw.bundle_green` will need to include][2]
dependencies for .NET 6, such as:
net6.0-android
SQLitePCLRaw.core (>= 2.0.4)
SQLitePCLRaw.lib.e_sqlite3.android (>= 2.0.4)
SQLitePCLRaw.provider.e_sqlite3 (>= 2.0.4)
net6.0-ios
SQLitePCLRaw.core (>= 2.0.4)
SQLitePCLRaw.provider.dynamic_cdecl (>= 2.0.4)
This will solve the problem for customers going forward.
[0]: https://www.nuget.org/packages/SQLitePCLRaw.bundle_green/
[1]: https://www.nuget.org/packages/SQLitePCLRaw.lib.e_sqlite3.android/
[2]: ericsink/SQLitePCL.raw#383
0 commit comments