openwebf / mercury

A library with integrated JavaScript engine and extension utils for Flutter Apps.
Apache License 2.0
12 stars 3 forks source link

Binary linking is failing #30

Open arifinreinaldo opened 1 month ago

arifinreinaldo commented 1 month ago
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.0, on macOS 14.5 23F79 darwin-arm64, locale en-SG)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.88.1)
[✓] Connected device (3 available)
[✓] Network resources

step to replicate : run this code on the Flutter :

        var mercuryjs = Mercury(
            devToolsService: ChromeDevToolsService(),
            bundle: MercuryBundle.fromContent(jsFile),
            onControllerCreated: (controller) {
              controller.onLoad = (controller) {
                controller.context.dispatcher?.subscribe('example', (args) {});
                controller.context.evaluateJavaScripts('hello();');
              };
            });

flutter: Invalid argument(s): Failed to load dynamic library 'mercury_bridge.framework/mercury_bridge': dlopen(mercury_bridge.framework/mercury_bridge, 0x0001): tried: 'mercury_bridge.framework/mercury_bridge' (no such file), '/private/preboot/Cryptexes/OSmercury_bridge.framework/mercury_bridge' (no such file), '/usr/lib/swift/mercury_bridge.framework/mercury_bridge' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/mercury_bridge.framework/mercury_bridge' (no such file), '/private/var/containers/Bundle/Application/E7D741FB-98F0-4EBE-B316-40FCEE308A6C/Runner.app/Frameworks/mercury_bridge.framework/mercury_bridge' (no such file), '/private/var/containers/Bundle/Application/E7D741FB-98F0-4EBE-B316-40FCEE308A6C/Runner.app/Frameworks/mercury_bridge.framework/mercury_bridge' (no such file), '/usr/lib/mercury_bridge.framework/mercury_bridge' (no such file, not in dyld cache), 'mercury_bridge.framework/mercury_bridge' (no such file)

tried to do flutter clean faced with new error

Could not build the precompiled application for the device.
Semantic Issue (Xcode): Unknown receiver 'MercuryjsPlugin'; did you mean 'MercuryPlugin'?
/Users/reinaldoarifin/FlutterProjects/flutter_rad/ios/Runner/GeneratedPluginRegistrant.m:233:3
MulverineX commented 1 month ago

@arifinreinaldo is this specifically an issue for iOS?

Also, we need to confirm which version of mercury you are running.

MulverineX commented 1 month ago

image image Looks like both versions have a valid binary available, is this a symlinking problem?

arifinreinaldo commented 1 month ago

I tried with android build

..\Cache\hosted\pub.dev\mercuryjs-0.1.3\android\src\main\java\com\openwebf\mercuryjs\MercuryjsPlugin.java:16: error: class MercuryPlugin is public, should be declared in a file named MercuryPlugin.java
public class MercuryPlugin implements FlutterPlugin, MethodCallHandler {
       ^
..\Local\Pub\Cache\hosted\pub.dev\mercuryjs-0.1.3\android\src\main\java\com\openwebf\mercuryjs\MercuryjsPlugin.java:24: error: cannot find symbol
  private Mercury mMercury;
          ^
  symbol:   class Mercury
  location: class MercuryPlugin
..\Local\Pub\Cache\hosted\pub.dev\mercuryjs-0.1.3\android\src\main\java\com\openwebf\mercuryjs\MercuryjsPlugin.java:51: error: cannot find symbol
  Mercury getMercury() {
  ^
  symbol:   class Mercury
  location: class MercuryPlugin
..\Local\Pub\Cache\hosted\pub.dev\mercuryjs-0.1.3\android\src\main\java\com\openwebf\mercuryjs\MercuryjsPlugin.java:53: error: cannot find symbol
      mMercury = Mercury.get(flutterEngine);
                 ^
  symbol:   variable Mercury
  location: class MercuryPlugin
..\Local\Pub\Cache\hosted\pub.dev\mercuryjs-0.1.3\android\src\main\java\com\openwebf\mercuryjs\MercuryjsPlugin.java:74: error: cannot find symbol
        Mercury mercury = getMercury();
        ^
  symbol:   class Mercury
  location: class MercuryPlugin
..\Local\Pub\Cache\hosted\pub.dev\mercuryjs-0.1.3\android\src\main\java\com\openwebf\mercuryjs\MercuryjsPlugin.java:89: error: cannot find symbol
    Mercury mercury = Mercury.get(flutterEngine);
    ^
  symbol:   class Mercury
  location: class MercuryPlugin
..\Local\Pub\Cache\hosted\pub.dev\mercuryjs-0.1.3\android\src\main\java\com\openwebf\mercuryjs\MercuryjsPlugin.java:89: error: cannot find symbol
    Mercury mercury = Mercury.get(flutterEngine);
                      ^
  symbol:   variable Mercury
  location: class MercuryPlugin
..\Local\Pub\Cache\hosted\pub.dev\mercuryjs-0.1.3\android\src\main\java\com\openwebf\mercuryjs\MercuryjsPlugin.java:91: error: cannot find symbol
    mercuryjs.destroy();
    ^
  symbol:   variable mercuryjs
  location: class MercuryPlugin
Note: ..\Local\Pub\Cache\hosted\pub.dev\mercuryjs-0.1.3\android\src\main\java\com\openwebf\mercuryjs\MercuryjsPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
8 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mercuryjs:compileReleaseJavaWithJavac'.

turns out also unable to build the apk

MulverineX commented 1 month ago

Those appear to be Windows paths? What operating system are you using?

arifinreinaldo commented 1 month ago

the

@arifinreinaldo is this specifically an issue for iOS?

Also, we need to confirm which version of mercury you are running.

the version is mercuryjs: ^0.1.3

arifinreinaldo commented 1 month ago

Those appear to be Windows paths? What operating system are you using?

for android testing currently I'm using WIndows, previously for iOS I'm using Mac

MulverineX commented 1 month ago

I will try to reproduce your issue on building for Android on Windows

@ekkis when he has time can hopefully help with MacOS (I do not have a MacOS environment)

MulverineX commented 1 month ago

I'll work on this after my day job, probably sometime around 7pm Mountain Time

Thanks for the report, we'll get back to you soon :)

arifinreinaldo commented 1 month ago

I'll work on this after my day job, probably sometime around 7pm Mountain Time

Thanks for the report, we'll get back to you soon :)

thanks, let me know if you need any additional information

MulverineX commented 1 month ago

Oh and to be clear, you're trying to use Mercury for an app through pub.dev, right? (you don't have this repository cloned)

MulverineX commented 1 month ago

@arifinreinaldo

arifinreinaldo commented 1 month ago

Oh and to be clear, you're trying to use Mercury for an app through pub.dev, right? (you don't have this repository cloned)

I'm using flutter pub add mercuryjs, is there spesific method that I have to follow?

MulverineX commented 1 month ago

Nope, that should be it, just wanted to confirm. Thank you

MulverineX commented 1 month ago

@arifinreinaldo It turns out this is a problem when compiling for any platform! It's embarrassing that we missed this! So, it appears that actually using the library as a package installed from pub.dev doesn't work, but it does work within the example project when in the mercury workspace. As it currently stands this means the package can't be used in any project! We will be fixing this soon, apologies for the delay.

arifinreinaldo commented 1 month ago

@arifinreinaldo It turns out this is a problem when compiling for any platform! It's embarrassing that we missed this! So, it appears that actually using the library as a package installed from pub.dev doesn't work, but it does work within the example project when in the mercury workspace. As it currently stands this means the package can't be used in any project! We will be fixing this soon, apologies for the delay.

ok, hopefully can be fixed soon. Thanks

oluul commented 1 month ago

How's this issue coming along?

MulverineX commented 1 month ago

Been doing some tinkering, I believe we have some broken Flutter Plugin files, starting tomorrow I'm going to comb through their differences to upstream and attempt to get this resolved within a few days.

I also discovered a nasty memory allocation bug in the bridge library that affects Windows, about halfway through that, still getting crashes, will continue to look through upstream fixes.

MulverineX commented 1 month ago

A good chunk of the way through this now, those interested can track progress here: https://github.com/openwebf/mercury/pull/35

arifinreinaldo commented 3 weeks ago

A good chunk of the way through this now, those interested can track progress here: #35

Hi, thanks for keeping posted about the progress so far. CMIIW, so the fix will be handled in the version 0.2.0?

MulverineX commented 3 weeks ago

Yep