Skip to content

Microsoft.EntityFrameworkCore.SQLite on Android 7+ not working #8922

Closed as not planned

Description

@tipa

I was successfully using Microsoft.EntityFrameworkCore.SQLite v.1.1.2 in a Xamarin.Android project. But for Android 7+, the app crashes with unauthorized access to "/system/lib64/libsqlite.so" (as reported here).

So I updated to version v2.0.0-preview1-final as this should fix the issue.
However, this results in other problems like the following where the app compiled, but crashed while deploying/starting on the emulator:

...
06-21 09:58:18.970 D/Mono    ( 3632): Assembly Loader probing location: 'System.Runtime.CompilerServices.Unsafe'.
06-21 09:58:18.970 F/monodroid-assembly( 3632): Could not load assembly 'System.Runtime.CompilerServices.Unsafe' during startup registration.
06-21 09:58:18.970 F/monodroid-assembly( 3632): This might be due to an invalid debug installation.

I then tried to add the 'System.Runtime.CompilerServices.Unsafe' NuGet package manually to my project, but it didnt fix the problem. I messed around a lot, trying different build parameters and such and actually got the app running on an Android 7 emulator. However, after a project clean and rebuild, the error showed up again.

Any help on how to get EFCore Sqlite to work on Android 7?

Steps to reproduce

Sample project: https://github.com/tipa/EFCoreSample
(Basically just the basic Android template from VS + the Nuget preview package)

Further technical details

EF Core version: v2.0.0-preview1-final
Database Provider: Microsoft.EntityFrameworkCore.Sqlite
Xamarin: 4.5.0.486
Xamarin.Android: 7.3.1.2
Operating system: Windows 10
IDE: Visual Studio 2017 15.2

Activity

  1. added this to the Backlog milestone on Jun 21, 2017
  2. tipa commented on Aug 18, 2017

    @tipa
    Author

    Any comments/updates on this?

  3. bricelam commented on Aug 18, 2017

    @bricelam
    Contributor

    Have you tried again with EF Core version 2.0.0 and Xamarin.Android 7.5?

  4. tipa commented on Aug 18, 2017

    @tipa
    Author

    How can I test it with Xamarin.Android 7.5? Version 7.4 was just released a few days ago

  5. erikpowa commented on Aug 19, 2017

    @erikpowa

    @tipa Xamarin Updater Extension for VS 2017 (market). For older version of VS you can switch channels in vs->options->xamarin (not sure if alpha or beta).
    I had the same error so I updated everything to the latest version, VS + NET Core (2.0+) + Xamarin Preview (I'm using Xamarin.Android 7.5.0.3 ), and everything is fine since then.

  6. tipa commented on Aug 19, 2017

    @tipa
    Author

    @erikpowa that means I am forced to use VS17 Preview in order to use Xamarin.Android 7.5, is that correct? I would probably even do that if that finally resolves that issue.

    Edit: well, downloaded VS17 preview + Xamarin.Android 7.5, however they still seem to be very beta, I encounter several issues which make it impossible for me to even compile the app.

  7. NPadrutt commented on Aug 22, 2017

    @NPadrutt

    I have the same issue on the current stable and on the preview of Xamarin. But I still have the same issue..

  8. bricelam commented on Aug 22, 2017

    @bricelam
    Contributor

    (Marking for re-triage. Xamarin supports .NET Standard 2.0 now, but this still seems to be blocked.)

  9. removed this from the Backlog milestone on Aug 22, 2017
  10. added this to the 2.1.0 milestone on Aug 23, 2017
  11. groege commented on Sep 4, 2017

    @groege

    Hi, this is very serious for us, since we are already shipping the Android app with netstandard1.4.
    For now just no one use a Android 7+ phone, but now we might loose many important customers if we can't get it working very soon.
    Can you give me any advice on how to handle this? Is there any workaround to make it work on Android 7+?
    I'd be grateful for any help. Thanks.

  12. NPadrutt commented on Sep 4, 2017

    @NPadrutt

    If you target 6.0 with your app and use EF 1.x it should work on Android 7+ as well. There is a message shown sometimes when you start, but you can just hit ok and it should be functional.

  13. groege commented on Sep 4, 2017

    @groege

    Thank you! Didn't think there was an easy solution like this (though i also added this: #7870).
    For now this is the better solution anyway until we can upload UWP projects to the app store with netcore2.0 ;)

  14. 30 remaining items

  15. dfoulk commented on Jan 19, 2018

    @dfoulk

    @ddobrev - Yes, thank you for that. We're converting these projects to package.config- but a few errors seem to be preventing us from deploying still...

    After following the instructions you provided in another thread:

    Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog'.

    No resource found that matches the given name: attr 'windowActionModeOverlay'.

    styles.xml has apparently ran into some issues as a result :(

    Update:

    Something was wrong with our initial conversion. We reverted and tried again and all ended up okay... Thanks again!

  16. ddobrev commented on Jan 20, 2018

    @ddobrev

    @dfoulk you're welcome. About that error, your conversion was just fine - it's just that Xamarin.Android is notoriously poor at rebuilding. Every time a major restructuring, such as yours, takes place, the only way to properly rebuild everything is after deleting your bin/ and obj/ - that is, neither rebuild nor clean + build work in such cases.

  17. jnormen commented on Feb 2, 2018

    @jnormen

    Any news here? I cannot go back to 1.3 :( And really need EF with SQLite to work on our app in Android. How is this long delay of a fix even possible? :(

  18. dazinator commented on Feb 2, 2018

    @dazinator

    I am using it in our monodroid 8 app - it is working.. I had to convert the project to using packages.xml instead of packagereference though.. I'm waiting for this issue to be fixes so that I can convert back to packagereference and drop packages.xml again..

  19. jnormen commented on Feb 2, 2018

    @jnormen

    yes, it's the package reference scenario I want them to fix. It has been many converts back and forth already, because of other libs and I'm done spending time converting, my clients do not pay for that job :(

  20. removed their assignment
    on Feb 5, 2018
  21. removed this from the 2.1.0 milestone on Feb 5, 2018
  22. divega commented on Feb 5, 2018

    @divega
    Contributor

    Clearing milestone to decide in triage whether we want to keep this for tracking purposes or whether we should close.

    The underlying issues in Xamarin Android are now tracked in dotnet/android#1154 and dotnet/android#1196.

  23. dfoulk commented on Feb 5, 2018

    @dfoulk

    Thanks for the update @divega

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions