Open ko16a46 opened 3 days ago
Thanks for the report! Are you using an emulator with 16KiB page sizes? (if not sure, run adb shell getconf PAGE_SIZE
)? I can't reproduce this with a 4KiB emulator on API 35. And even a fresh flutter create
project crashes with 16KiB pages, so I can't diagnose that further.
Are you using drift_flutter
or, if not, are you calling applyWorkaroundToOpenSqlite3OnOldAndroidVersions()
somewhere?
Hello, yes it turns out I'm using the 16KiB page size on my emulator
KO16A46@LXHP0G54C6N kohler_flutter_apps % adb shell getconf PAGE_SIZE
16384
Hmm interesting that I can get my app to run on the emulator when it sounds like you may be having issues. I tried running a vanilla flutter create
app on this 16KiB emulator and it works for me. Note that I am on Flutter 3.24.3.
I did try running my app on an Android API 35 emulator without 16KiB paging and I can confirm that I see no errors. So it sounds like the 16KiB page size is actually the root issue.
Also to answer your other questions, we are actually not using drift_flutter
, would you recommend we try that? We are also not calling applyWorkaroundToOpenSqlite3OnOldAndroidVersions()
either (although actually we should probably investigate and try using this)
Interesting, I have the same Flutter version. Is this an x86 or an arm emulator?
I only mentioned drift_flutter
because it invokes the workaround automatically, and I suspect it might be related to this. The method essentially invokes System.loadLibrary
in Java, which is not exactly the same thing as dlopen
/DynamicLibrary.open
because it's also able to open the library from the apk directly without an explicit decompression step. The Android 15 changelog mentioned that method specifically continuing to work with 16 KiB pages, so maybe that fixes this (if it does, it obviously still something worth looking at, ideally this should continue to work automatically).
Noted thanks, I will try out drift_flutter
later and see if that affects the issue
Interesting, I have the same Flutter version. Is this an x86 or an arm emulator?
I'm using an arm64 image on my Android emulator.
Also note that I am running it on an M1 Macbook Pro.
Hello,
FYI I tried using driftDatabase()
within drift_flutter
on my Android API 35 emulator with 16KiB page size
Unfortunately it seems that failed too, but the error message does appear to be more useful
D/nativeloader( 7526): Load /data/app/~~e75lMYiyAe5h8a1LPKr-KA==/com.kohlerpower.dealerservice-j6-CJ_8pWOC3SsHnxkMFpg==/lib/arm64/libsqlite3.so using ns clns-7 from class loader (caller=/data/app/~~e75lMYiyAe5h8a1LPKr-KA==/com.kohlerpower.dealerservice-j6-CJ_8pWOC3SsHnxkMFpg==/base.apk!classes2.dex): dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/~~e75lMYiyAe5h8a1LPKr-KA==/com.kohlerpower.dealerservice-j6-CJ_8pWOC3SsHnxkMFpg==/lib/arm64/libsqlite3.so" (new hash type from the future?)
E/flutter ( 7526): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/~~e75lMYiyAe5h8a1LPKr-KA==/com.kohlerpower.dealerservice-j6-CJ_8pWOC3SsHnxkMFpg==/lib/arm64/libsqlite3.so" (new hash type from the future?), null, null, null)
E/flutter ( 7526): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
E/flutter ( 7526): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
E/flutter ( 7526): <asynchronous suspension>
E/flutter ( 7526): #2 applyWorkaroundToOpenSqlite3OnOldAndroidVersions (package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart:32:5)
E/flutter ( 7526): <asynchronous suspension>
E/flutter ( 7526): #3 driftDatabase.<anonymous closure> (package:drift_flutter/src/native.dart:42:9)
E/flutter ( 7526): <asynchronous suspension>
E/flutter ( 7526): #4 new DatabaseConnection.delayed.<anonymous closure> (package:drift/src/runtime/api/connection.dart:67:39)
E/flutter ( 7526): <asynchronous suspension>
E/flutter ( 7526):
E/flutter ( 7526): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/~~e75lMYiyAe5h8a1LPKr-KA==/com.kohlerpower.dealerservice-j6-CJ_8pWOC3SsHnxkMFpg==/lib/arm64/libsqlite3.so" (new hash type from the future?), null, null, null)
E/flutter ( 7526): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
E/flutter ( 7526): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
E/flutter ( 7526): <asynchronous suspension>
E/flutter ( 7526): #2 applyWorkaroundToOpenSqlite3OnOldAndroidVersions (package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart:32:5)
E/flutter ( 7526): <asynchronous suspension>
E/flutter ( 7526): #3 driftDatabase.<anonymous closure> (package:drift_flutter/src/native.dart:42:9)
E/flutter ( 7526): <asynchronous suspension>
E/flutter ( 7526): #4 new DatabaseConnection.delayed.<anonymous closure> (package:drift/src/runtime/api/connection.dart:67:39)
E/flutter ( 7526): <asynchronous suspension>
E/flutter ( 7526):
I searched around and it appears that Realm had a similar issue here with the suggestion to compile libraries using 16KB ELF alignment as a fix (as seen in this Realm PR).
I suppose you'd need to recompile your sqlite-native-libraries with 16KB ELF alignment to fix the issue? At least, that's what it looks like to me, but admittedly it's a bit out of my depth hehe. Feel free to message if you need help with testing
Hello, we've been doing a round of updating our apps' Flutter version, deps, etc. and we've been getting errors on our app with
drift
, usingsqlite3
under the hood.Notably the error only appears on the Android 15 (API 35) emulator so far, not on our real devices with older Android versions (I tested on my Galaxy S24+ with Android 14), and not on my Android API 32 emulator.
The error is as follows:
We create our database in a fairly standard way (using
drift
):Here are some of the relevant deps in our
pubspec.yaml
:And
pubspec.lock
(which should be up to date as we just ranflutter pub upgrade --major-versions
):Flutter doctor output (we are now on the latest version of Flutter):
I tried unzipping the APK that gets generated when running on the API 35 emulator, and I do see
libsqlite3.so
under each of thelib/<platform>/
foldersLet me know if you need more information. Unfortunately we don't have any real devices with Android 15.0 to test with yet, just emulators so far.