GregoryConrad / mimir

⚡ Supercharged Flutter/Dart Database
https://pub.dev/packages/mimir
MIT License
120 stars 8 forks source link

Can't get instance. #188

Closed AndriyChaban closed 1 year ago

AndriyChaban commented 1 year ago

on the initial Mimir.getInstance command I should provide libembedded_milli.so file. However, can't find it anywhere. Pretty sure this is not the issue in package. But, unfortunately, cannot solve it by myself. On the readme page no info on that.

GregoryConrad commented 1 year ago

@AndriyChaban Are you using Flutter, or Dart-only?

AndriyChaban commented 1 year ago

I tried both. In flutter the command Mimir.getDefaultInstance throws above mentioned error. Tried with dart-only all getInstance variants too. Asks the path to that file.

GregoryConrad commented 1 year ago

@AndriyChaban If you are using Flutter, you should be using one of the methods mentioned here:

  1. Mimir.defaultInstance for 99.9% of use cases
  2. Mimir.getInstanceForName for when you need another instance for some reason, but in the default location
  3. Mimir.getInstanceForPath for when you need to override the entire path of the database

You should not being using getInstance directly in Flutter.

throws above mentioned error

You didn't really provide any error details (i.e., device, stack trace, etc.); would you mind sharing them please (assuming you used one of the 3 methods listed directly above)?

AndriyChaban commented 1 year ago

At first I tried to get an instance in my local dart package inside Flutter project. Tried all. Then, as an experiment, tried to get instance with Mimir.defaultInstance inside main.dart. Got the following:

E/flutter (17760): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libembedded_milli.so': dlopen failed: library "libembedded_milli.so" not found E/flutter (17760): #0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:43) E/flutter (17760): #1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12) E/flutter (17760): #2 createLibraryImpl (package:flutter_mimir/src/ffi/io.dart:16:27) E/flutter (17760): #3 FlutterMimirInterface.getInstanceForPath (package:flutter_mimir/src/flutter_interface.dart:35:40) E/flutter (17760): #4 FlutterMimirInterface.getInstanceForName (package:flutter_mimir/src/flutter_interface.dart:24:14) E/flutter (17760): E/flutter (17760): #5 main (package:my_dictionary/main.dart:27:20) E/flutter (17760):

GregoryConrad commented 1 year ago

@AndriyChaban I'm guessing you are using Android/Linux then, in which case the .so file probably failed to download when you were building the project. Delete any build output folders (like build/) and run flutter clean. Even better, if you are using git, something like git clean -xfd would work well (but take a look at what that does before blindly running it!).

Note: until Dart releases "native assets", you will need a semi-decent Internet connection in order to build projects using mimir (and it might take a few minutes to download the necessary binaries). Unfortunately, there is nothing I can do about that at the moment.

AndriyChaban commented 1 year ago

Thank you for prompt replies. Maybe my mobile internet speed does not comply with the requirements of 'semi-decent Internet connection' category... Will try again later.

AndriyChaban commented 1 year ago

probably it is Android issue since windows build works well.

GregoryConrad commented 1 year ago

Closing this as it is highly likely that you just need to clean your Flutter/Dart build cache for Android and retry (and if you have a flaky Internet connection, it may take a few tries).