-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Unable to load dynamic library with FFI on some devices #73318
Comments
We also have other users reporting issues with Android <= 6. Though, we've not been able to pinpoint a solution. Possible workarounds:
/**
* The loader for the X native library.
*
* This plugin is purely a workaround. On API versions <=23, it is possible to
* call an Android SDK method that loads a native library that changes the paths searched when
* `DynamicLibrary.open` is called in Dart.
*
* As such, this plugin is configured to load the shared library when it is registered, so that
* when `DynamicLibrary.open('libX.so')` is called subsequently through Dart, it will be a
* no-op.
*/
public final class XLoader implements FlutterPlugin {
@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
loadLibrary();
}
@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {}
private static boolean isLibraryLoaded = false;
private static void loadLibrary() {
if (isLibraryLoaded) {
return;
}
// Loads `libX.so`.
System.loadLibrary("X");
isLibraryLoaded = true;
}
} |
@dcharkes Thank you for your helpful answer. I have now implemented the second workaround that you suggested (calling My specific problem is now solved, so I will close this issue. From what I understand Dart SDK issue #37771 and Flutter issue #59834 address the cause of the problem, so when those issues are solved, this workaround can be removed from the application. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
My Flutter app distributed on the Google Play store seems to be unable to load a packaged dynamic library on a few devices. They are ARM devices I believe, and the APK distributed to those devices do seem to contain the
libraster.so
library (built and packaged using Cmake/NDK. It is difficult for me to test this as I don't have these particular devices to try to reproduce the test on.Steps to Reproduce
ArgumentException
Expected results:
The library is loaded successfully.
Actual results:
The library is unable to be found and so can not be loaded with the following error:
Affected devices
Since the library does load successfully on many other devices, I'm unsure what the cause of this could be. Assuming this is a Dart/Flutter related issue, I have excluded some details of my Gradle build here. There are more details on my StackOverflow question.
Flutter doctor output
The text was updated successfully, but these errors were encountered: