firstfloorsoftware / flutter_sodium

Flutter bindings for libsodium
BSD 3-Clause "New" or "Revised" License
102 stars 47 forks source link

Failed to lookup symbol (dlsym(RTLD_DEFAULT, crypto_box_seedbytes): symbol not found) #39

Closed nailkhasipov closed 3 years ago

nailkhasipov commented 3 years ago

[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, crypto_box_seedbytes): symbol not found)

0 DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:31:29)

1 Bindings.lookupSizet (package:flutter_sodium/src/bindings/libsodium.dart:29:14)

2 new CryptoBoxBindings (package:flutter_sodium/src/bindings/crypto_box_bindings.dart:9:17)

3 Sodium._cryptoBox (package:flutter_sodium/src/sodium.dart:35:29)

4 Sodium._cryptoBox (package:flutter_sodium/src/sodium.dart)

5 Sodium.cryptoBoxPublickeybytes (package:flutter_sodium/src/sodium.dart:190:7)

6 Sodium.cryptoBoxKeypair (package:flutter_sodium/src/sodium.dart:226:40)

7 CryptoBox.randomKeys (package:flutter_sodium/src/crypto_box.dart:10:41)

8 generateKeys (package:vlow/screens/onboarding_screen.dart:171:36)

9 _OnboardingState.create (package:vlow/screens/onboarding_screen.dart:47:28)

10 GestureRecognizer.invokeCallbac<…>

Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.6 19G73, locale en-GB)

soyangel commented 3 years ago

Same error here with Flutter 1.20.2.

It works after downgrading to Flutter 1.17.5.

rohansingh commented 3 years ago

Same issue with Flutter 1.20.2. I won't pretend to understand the underlying issue, but I was able to workaround it by reverting to a pre-FFI revision (0575e585b3c6ed421e218eded97f461e12a370c4).

kozw commented 3 years ago

Related: https://github.com/flutter/flutter/issues/62853

soyangel commented 3 years ago

Does the workaround mentioned on https://github.com/flutter/flutter/issues/62853 works with this plugin?

I'm trying with a modified pubspec.yaml including with the "platforms:" section but get the same error.

kozw commented 3 years ago

That issue is definitely related. However the problem is not pubspec.yaml, but the podspec which has changed significantly since Flutter 1.20. Still looking for a solution though.

vishnukvmd commented 3 years ago

Downgrading Flutter to 1.19.0-4.3.pre solved this for me (I had to say goodbye to a few nice things, but better them than libsodium).

@kozw What is weird is that the example app you've been kind enough to provide works well with Flutter 1.20.4 (stable). But my application freezes with (dlsym(RTLD_DEFAULT, sodium_init): symbol not found). Copying the missing elements from the example's Podfile, did not help.

kozw commented 3 years ago

You most likely get a warning that the Podfile is out of date. When you remove the podfile in example/ios folder, it will be regenerated with something different in flutter 1.20 and you'll get the same error.

It's still a mystery to me would I need to do to fix this.

kozw commented 3 years ago

Scratch that previous comment. Just had a brainwave and flutter_sodium now seems to work with flutter 1.20.

Please try 0.1.5 available in pub.dev.

rohansingh commented 3 years ago

Hmm, 0.1.5 fails to build on Android:

/Users/rohan/tidbyt/flutter/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:16: error: cannot find symbol
import com.firstfloorsoftware.flutter_sodium.FlutterSodiumPlugin;
                                            ^
  symbol:   class FlutterSodiumPlugin
  location: package com.firstfloorsoftware.flutter_sodium
/Users/rohan/tidbyt/flutter/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:46: error: cannot find symbol
    FlutterSodiumPlugin.registerWith(registry.registrarFor("com.firstfloorsoftware.flutter_sodium.FlutterSodiumPlugin"));
    ^
  symbol:   variable FlutterSodiumPlugin
  location: class GeneratedPluginRegistrant
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 51s
Exception: Gradle task assembleDebug failed with exit code 1
kozw commented 3 years ago

My bad, fixed in 0.1.6. All should be good now.

rohansingh commented 3 years ago

Just confirming, 0.1.6 works beautifully. Thanks so much!

kozw commented 3 years ago

Good to hear, enjoy!

nailkhasipov commented 3 years ago

Also confirmed that 0.1.6 works perfectly with Flutter 1.22.0 beta. Thanks! 🎉