I've forked the Jon Douglas EntityFrameworkWithXamarin example to tbalcom/EntityFrameworkWithXamarin. When I run this on an Android 7 device I see an error popup from the system:
Detected problems with app native libraries (please consult log for detail): libmonosgen-64bit-2.0.so: unauthorized access to "/system/lib64/libsqlite.so"
There is an explanation for the error message here. Entity Framework Core appears to be using SQLite "incorrectly" on Android, which is triggering the system error. Note this is not a problem on Android versions 6.0 and earlier.
Run either project tbalcom/EntityFrameworkWithXamarin or jondouglas/EntityFrameworkWithXamarin on an Android 7.0 or later device/emulator. The error popup from the system will appear as the MainActivity is shown.
EF Core version: 1.1.0
Database Provider: (e.g. Microsoft.EntityFrameworkCore.Sqlite)
Operating system: Android 7.0
IDE: Visual Studio 2015 w/ Update 3
Xamarin: 4.3.0.784
Xamarin.Android: 10.4.0.123
We've mitigated this in the next release by leveraging SQLitePCL.raw that already handles Android N. Feel free to test it out using the nightly MyGet feed.
@bricelam What is the solution today? We are using:
Microsoft.EntityFrameworkCore 1.1.2
Microsoft.EntityFrameworkCore.Sqlite 1.1.2
Is it possible to override the version of SQLitePCL.raw that used by EF?
Versions 1.x don't use SQLitePCL.raw. They use the official sqlite package which doesn't support Xamarin. You'd need to distribute your own copy of libsqlite3.so with the app.
How exactly would one go about doing something like that? Is there an expected release date for this update to change over to the SQLitePCL.raw?
This is a big show-stopper in my project as well. Any way to get EF running on Android 7 currently?
Has anyone figured out a solution for this?
Since the next version targets .net standard 2.0 and I have a UWP to support this isn't a valid option until fall when they ship .net standard 2.0 for UWP.
I upgraded Microsoft.Data.Sqlite to version 2.0.0-preview2-final but not the rest of EFCore. That seems to work for me. I'm no longer getting a unauthorised access message.
@bricelam: is there any chance of a solution for those of us who still want to be on .NET Standard 1.4?
I have a UWP app that uses a .NET Standard 1.4 "core" library to contain its business logic. I'm working on building a Xamarin Forms UI on top of that as well, currently aiming at Android. The core library uses Entity Framework on top of Sqlite. So naturally it's running into this issue on Android.
I'd like to upgrade the core library to .NET Standard 2.0 in order to pick up the latest EF Core, but there are two problems with that:
Doing so loses support for Windows 10 Creator's Update as well as what's left of Windows 10 Mobile. That might be an option in the future, but certainly not at the moment.
Entity Framework Core 2.0.1 throws NullReferenceExceptions opening existing sqlite databases created by 1.1.5. cf stack trace [1] below. Not super-encouraging.
You'd need to distribute your own copy of libsqlite3.so with the app.
Is that an actual suggestion? Any idea how to do that with a Xamarin app?
[1]
0x0 in Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject.GetValue C# Annotated Frame
0x3 in object.lambda_method C# Annotated Frame
0x19 in System.Linq.Lookup<int?,Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject>.CreateForJoin C# Annotated Frame
0x5B in System.Linq.Enumerable.<JoinIterator>d__81<Backroads.Day,Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject,int?,Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.TransparentIdentifier<Backroads.Day,Microsoft.EntityFrameworkCore.Query.Internal.JoinIterator C# Annotated Frame
0x33 in System.Collections.Generic.EnumerableHelpers.ToArray<Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.TransparentIdentifier<Backroads.Day,Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject>> C# Annotated Frame
0x2A in System.Linq.Buffer<Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.TransparentIdentifier<Backroads.Day,Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject>>..ctor C# Annotated Frame
0x25 in System.Linq.OrderedEnumerable<Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.TransparentIdentifier<Backroads.Day,Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject>>.GetEnumerator C# Annotated Frame
0x2F in System.Linq.Enumerable.SelectIPartitionIterator<Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.TransparentIdentifier<Backroads.Day,Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject>,Backroads.Day>.MoveNext C# Annotated Frame
0x26 in Microsoft.EntityFrameworkCore.Query.Internal.QueryBuffer.IncludeCollection C# Annotated Frame
0xA7 in object.lambda_method C# Annotated Frame
0xC in Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler._Include<Backroads.Trip> C# Annotated Frame
0x4F in object.lambda_method C# Annotated Frame
0x48 in System.Linq.Enumerable.SelectIPartitionIterator<Backroads.Trip,Backroads.TripViewModel>.MoveNext C# Annotated Frame
0x1C in Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor<Backroads.TripViewModel>.EnumeratorExceptionInterceptor.MoveNext C# Annotated Frame
@bricelam we are using Xamerin and Target framework is 4.4. We are getting this warning everytime when we launch our application through debug mode. We are using Couchbase.Lite which internally uses SQLitePCL.raw 0.8.0.
We can not migrate to latest Couchbase.Lite as we are having big set of .NET Framework 4.5.1 (PCL) class libraries. Is there any solution you can provide for getting rid of this issue?
(See ericsink/SQLitePCL.raw#277 for more backstory)
@BhushanKD Adding a comment to a closed issue that is 2 years old may not yield a reply.
There is no workaround for the Android N system SQLite issue except to bundle your own SQLite library.
If you cannot migrate to the latest Couchbase Lite, then you have no easy way forward. Anything you do is going to be a significant amount of work.
Most helpful comment
This is a big show-stopper in my project as well. Any way to get EF running on Android 7 currently?