openwebf / webf

Build flutter apps with HTML/CSS and JavaScript.
https://openwebf.com/
Apache License 2.0
1.63k stars 117 forks source link

libwebf.so load failed #66

Closed pba-cra closed 2 years ago

pba-cra commented 2 years ago

Affected version

main

No same issues found.

Steps to Reproduce

-

Code example

ArgumentError: Invalid argument(s): Failed to load dynamic library 'libwebf.so': dlopen failed: library "libwebf.so" not found

0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11)

1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:20)

2 WebfDynamicLibrary.ref (package:webf/src/bridge/dynamic_library.dart:40)

3 _registerPluginByteCode (package:webf/src/bridge/to_native.dart:257)

4 registerPluginByteCode (package:webf/src/bridge/to_native.dart)

Expected results

can load library

Actual results

some android platform(such as ,vivo/oppo, os 6.0) load libwebf.so error。

pba-cra commented 2 years ago

The error happen random on andorid platform which is vivo and oppo.

pba-cra commented 2 years ago

dart ffi have some error https://github.com/flutter/flutter/issues/73318?from_wecom=1#issuecomment-754598119

pba-cra commented 2 years ago

developer can use this code to resolve this problem

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;
  }
}