-
Notifications
You must be signed in to change notification settings - Fork 120
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
libobjectbox-jni.so not found on Android 6 and older #369
Comments
Thanks, but I can't reproduce this (using Android emulator). Could you share more details about the project, maybe even a small example project? Also what devices are you trying to run it on? |
Closing this issue due to inactivity. 💤 Feel free to comment with more details or submit a new issue. |
I have same question in app/build.gradle
flutter doctor [√] Flutter (Channel unknown, 2.10.5, on Microsoft Windows [Version 10.0.19044.1741], locale zh-CN)
• Flutter version 2.10.5 at
• Upstream repository unknown
• Framework revision 5464c5bac7 (8 weeks ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[√] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) ......
dependencies:
......
#db
objectbox: ^1.5.0
objectbox_flutter_libs: any
......
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^1.0.0
build_runner: ^2.1.11
objectbox_generator: any
...... // splash_controller.dart
......
@override
void onReady() {
super.onReady();
...
_store = await openStore().catchError((e) {
throw e;
});
...
}
...... I/flutter (17898): Failed to load ObjectBox library. For Flutter apps, check if objectbox_flutter_libs is added to dependencies. For unit tests and Dart apps, check if the ObjectBox library was downloaded (https://docs.objectbox.io/getting-started).
E/flutter (17898): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libobjectbox-jni.so': dlopen failed: library "libobjectbox-jni.so" not found
E/flutter (17898): #0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:12:43)
E/flutter (17898): #1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:23:12)
E/flutter (17898): #2 _tryObjectBoxLibFile (package:objectbox/src/native/bindings/bindings.dart:77:29)
E/flutter (17898): #3 loadObjectBoxLib (package:objectbox/src/native/bindings/bindings.dart:94:12)
E/flutter (17898): #4 C (package:objectbox/src/native/bindings/bindings.dart:112:27)
E/flutter (17898): #5 C (package:objectbox/src/native/bindings/bindings.dart)
E/flutter (17898): #6 new Model (package:objectbox/src/native/model.dart:19:31)
E/flutter (17898): #7 new Store (package:objectbox/src/native/store.dart:117:21)
E/flutter (17898): #8 openStore (package:xxxxxx/objectbox.g.dart:276:5)
E/flutter (17898): <asynchronous suspension>
E/flutter (17898): #9 SplashController.onReady.<anonymous closure> (package:xxxxxx/pages/splash/splash_controller.dart:30:16)
E/flutter (17898): <asynchronous suspension>
E/flutter (17898): |
@quewen08 Can you analyze your APK or AAB file (e.g. open it with Android Studio) and make sure the |
This appears to be an issue on Android 6 and older and can possibly be solved by loading the library in Java, then trying again to load the library in Dart: simolus3/drift#895 Now I also see why #328 makes sense (though would not do this for all devices, only if users actively call a workaround method, e.g. like sqlite3_flutter_libs or if the code could detect it's running on Android 6 or older). @quewen08 Can you check what version of the Android Gradle Plugin is used in your project? And maybe try updating to the latest version? Are you building APKs or App Bundles? I remember the Gradle plugin receiving some fixes so native libraries are extracted on Android 6 devices, which should avoid this issue. |
I think my gradle version is enough android/build.gradle buildscript{
...
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
...
} gradle/wrapper/gradle-wrapper.properties
|
@quewen08 Version 7.1.2 looks recent enough. You may try the suggestion about targeting Android 6.0 in the warning at https://docs.flutter.dev/deployment/android#building-the-app-for-release |
Hum, it seems useless. I tried add |
@quewen08 Thanks for trying! Then we probably have to add the workaround as described in my previous comment to a future release. (Note for me: see internal issue for details.) |
I had the same problem and I solved it: edit :
and changed it to :
-- What happened?Well, if |
didnt work here |
sorry, did not work, the app stuck on second load |
@mariovitor @kennir Are both of you trying to work with Android 6 devices? If not, could you please share what devices you are trying this on? |
Yes, Android 6 device. I fixed using Kotlin In MainActivity.kt:
created a method
Put openStore() in a try/catch
|
No, this is an android 5.1 device, I will try @mariovitor's solution later |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I just released a preview release If you are affected, it would help us if you could test if calling it before using any ObjectBox APIs resolves this issue on Android 6 devices (or older). E.g. something like: Future<void> main() async {
// This is required so ObjectBox can get the application directory
// to store the database in.
WidgetsFlutterBinding.ensureInitialized();
// Fix to load library on Android 6 devices (or older)
loadObjectBoxLibraryAndroidCompat();
objectbox = await ObjectBox.create();
runApp(const MyApp());
} If successful, we might consider calling this by default when e.g. using the |
@greenrobot-team, hello! We are affected by this issue and tried to switch to |
@Tumist76 and others: do you think that's worth that we put in some effort to call this automatically? (I'm a bit surprised to see Android 6 is still supported by app devs.) |
If there isn't any downsides, I think it'll be better to call this automatically so library usage is identical for those who support Android 6 and for those who don't. As for Android 6 support altogether - well, it's not like we want to support it, but it still has userbase so we're trying to cover it :) |
Just curious, what's the percentage of your users on Android 6? |
Really sorry, but I can't disclose this info. Let's just say that'll probably be cheaper to buy these users newer phones than for us to support Android 6 :) |
We have released version Let us know if this fixes the issue on Android 6 and 5 devices. If so, we will consider calling the compat method automatically on these devices in a future release. |
Thank you for fast release! We've updated our app to use |
Reporting back. We've passed the tests everything's fine on both Android 6.0 and later versions. We didn't test <Android 6.0 though. |
With the latest release ( |
Invalid argument(s): Failed to load dynamic library 'libobjectbox-jni.so': dlopen failed: library "libobjectbox-jni.so" not found
The text was updated successfully, but these errors were encountered: