-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Unhandled Exception: Invalid argument(s): Failed to load dynamic library (dlopen failed: library "libsqlite3.so" not found) #420
Comments
It shouldn't be related to the Flutter version. Can you please tell me which operating system and (os) version you're running your app on? Thanks! |
I'm running the flutter app in Linux Slackware64 14.2 and Android version 6.0.1. It working fine before updating the flutter while using the following moor dependencies:
|
Oh, that's interesting. Can you downgrade to |
Downgrading to Thank you. |
OK, I've found the source of the problem. It's because I'm using firebase_admob dependency. I'm calling the following line after initializing database:
It seems that it remove all the moor related folder in application document path so that the moor can't work anymore. Though this is only my wild guess right now. No problem with moor when removing the offending line. |
I forgot to tell you that I'm using a prepopulated database like in #346 case. I found a work around for this problem:
Initializing the admob directly after initializing the moor database won't work. Though I think there is something weird happened because of the admob :/ |
On Android, I'll take a good look at that when I have time, but it seems like it will be tough to track down and fix. Does this happen with a mostly-empty project that only uses |
I've tested it with moor_shared example in the moor project. The problem is consistent. Tested on Vivo 1610 device, Android 6.0.1, armeabi-v7a,armeabi. The problem can easily reproduced with the following steps:
|
After a couple times running my apps with admob_flutter dependency, I found that sometimes that the error:
still happens. Looks like Is this something related with the MethodChannel used by |
I've found that the |
I have same issue in my project. My device is Nexus 4 Android 5.0 armeabi-v7a. Curious to say, this looks like to fix it but I don't know why. class MainActivity: Activity() { // Entry point Activity of my app
// ...
companion object {
init {
System.loadLibrary("sqlite3")
}
}
} |
I found that some 64bit devices also have same problem. Probably it is Dart FFI's bug. |
@niusounds: That is a very good news! Does every error vanished when you're using |
It seems |
Same problem here the build target is for Android
|
I can confirm that the problem is fixed when using |
Hello, I am using:
[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18363.778], locale [√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) [√] Android Studio (version 3.6) [√] Connected device (1 available) This is the error message on windows: I already downloaded sqlite3.dll and added it to the path. Didn't change anything. Is there something I missed? Best regards |
@novas1r1 I don't have a lot of experience with Windows development. Does it work if you provide the absolute path manually? import 'dart:ffi';
import 'package:moor_ffi/open_helper.dart';
void main() {
open.overrideFor(OperatingSystem.windows, _openOnWindows);
}
DynamicLibrary _openOnWindows() {
return DynamicLibrary.open(r'C:\Path\to\sqlite3.dll');
} |
@simolus3 fixed it this morning by adding the whole sqlite3 tool-bundle from "Precompiled Binaries for Windows" in the path. sqlite3.dll wasn't enough for me. Thanks anyway for the alternate solution! |
I'm getting crash reports from one user. For now, it's only one user with a Sony Xperia Z3 Dual on Android 6.0. Stacktrace:
|
Am having the same proble. I try using DynamicLibrary _openOnWindows() { But did not work. Is there another working around. Where can i put the sqlite3 dll for this to work. |
@jesseframework On Windows you can also put @knaeckeKami |
In my first comment i did this:
Using this:
Is there another way to do it? what do you meant by your PATH? Am using moor_ffi: |
For now, it's just this one user with this one device. |
@simolus3 I can now reproduce this error locally on an old device that I had. If you need any more info, I'm glad to help. |
@knaeckeKami Can you reproduce flutter/flutter#54948 on that device? That's a similar problem we were seeing on old arm devices as well. If that minimal repro doesn't show any prolems, can you try to run moor's integration tests?
@jesseframework If you put the downloaded |
The device is a Samsung Galaxy S5. The projects both run without exceptions and all tests succeed. |
Interesting. And I thought I'll try calling DynamicLibrary.open with an absolute path.
with DynamicLibrary safeSqliteOpen() {
DynamicLibrary libsqlite;
try {
libsqlite = DynamicLibrary.open('libsqlite3.so');
} catch (e) {
print("fail, fallback 1");
libsqlite = DynamicLibrary.open(
"/data/data/<my app id>/lib/libsqlite3.so");
print('fallback success');
}
return libsqlite;
} but since I'm using the Isolates API, this doesn't work (the Isolate will have a separate Instance of the "open" object). So I forked moor_ffi and changed the _defaultOpen() method: DynamicLibrary _defaultOpen() {
if (Platform.isLinux || Platform.isAndroid) {
DynamicLibrary libsqlite;
try {
libsqlite = DynamicLibrary.open('libsqlite3.so');
} catch (e) {
print("fail, fallback 1");
libsqlite = DynamicLibrary.open(
"/data/data/<my app id>/lib/libsqlite3.so");
print('fallback success');
}
return libsqlite;
...
} And it worked! |
I still haven't received any new crashes with my workaround. I am pretty confident that it solves the problem. |
So I've come across the same problem: However, this didn't help - after executing it that way I got the error: After a bit of investigating in the build process I noticed that I got this warning The problem with my build was the automatically created Solution I hope this helps. TLDR |
I think that's a regression introduced in flutter 1.18, which leads to the .so file not being included in the apk at all.
My project uses flutter 1.17 stable, which still has the working settings.gradle, and I need the workaround in order to support some old android devices |
I've just released I'll keep this open for visibility, but it looks like the remaining failures aren't anything moor could fix. |
Changing the If I'm on the flutter master channel and run This was working a couple of months ago though. |
Same for
then apk is built and installed but using database causes Flutter error at runtime:
Flutter doctor
Manually editing
|
As @knaeckeKami said, there were two problems here:
I'll close this issue since it sounds like both problems are fixed now. |
Using Getting Test:
The database works normally, but when running the test I get:
libsqlite3-0 is installed. Flutter: channel dev |
@EmmanuelMess so you have a |
No, I do not. But |
The |
That worked thanks! |
If you were running into the issue where dependency_overrides:
moor_ffi:
git:
url: https://github.com/simolus3/moor.git
ref: develop
path: moor_ffi That version should work with the gradle files generated by the latest stable Flutter version as well. Please let me know if that doesn't fix the problem. |
I have a moor project working fine, but today I created a new one and I got the same error when it tries to create the db.
I am using:
|
Argh, sorry - it should be the dependency_overrides:
moor_ffi:
git:
url: https://github.com/simolus3/moor.git
ref: develop
path: moor_ffi Let me know if that works for you. |
Yes, now it works! |
this error occur to my also in mocOS pc and windows pc when create and run new project on android device and emulator |
Have the same problem for windows target, android works. The suggested dependency overwriting is not a solution for me, because I don't use the moor dependency since it called drift now. |
you probably need to include the sqlite.dll for windows. |
Edited by @simolus3 for visibility: If you encounter this problem, please check that you're using
moor_ffi
version0.6.0
or later. There's a Flutter bug causing builds to not include native libraries: flutter/flutter#55827 (comment). Please follow the workaround described in the linked comment.First, thank you very much for this wonderful project!
I've get a problem. After upgrading Flutter and run my Flutter with moor based project, I've get the following error:
I'm using the following moor dependencies:
Here my flutter doctor result:
Is this related to flutter version? If yes, what is the correct flutter version to temporarily fixing the problem?
Thank you.
The text was updated successfully, but these errors were encountered: