uniffi-rs
uniffi-rs copied to clipboard
UnsatisfiedLinkError: cannot locate symbol "SSL_do_handshake" in librustcore.so on Android / probably reqwest issue
trafficstars
UnsatisfiedLinkError: cannot locate symbol "SSL_do_handshake" in librustcore.so on Android
This probably has to do with: reqwest crate and its dependencies
Issue Description The application crashes on just calling any Rust function, even "say_hello() -> String" from Kotlin in simulator and on a SamsungS20FE with an UnsatisfiedLinkError. The same Rust core works reliably in iOS.
Steps to Reproduce (on MacMini M4) Build the rust-library:
# Set up cargo-ndk and add the Android targets
cargo install cargo-ndk
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
# Build the dylib
cargo build
# Build the Android libraries in jniLibs
cargo ndk -o ./android/app/src/main/jniLibs \
--manifest-path ./Cargo.toml \
-t armeabi-v7a \
-t arm64-v8a \
-t x86 \
-t x86_64 \
build
# Create Kotlin bindings
cargo run --bin uniffi-bindgen generate --library ./target/debug/librustcore.dylib --language kotlin --out-dir ./out
# copy to to android project
add to build.gradle.kts dependencies:
// Uniffi
implementation("net.java.dev.jna:jna:5.7.0@aar")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
- Build and install the application on an Android device/emulator.
- Launch the application.
- Run a test function even as simple as
say_hi(text: String) -> String {}which instantly crashes and closes the app on Android but not in iOS
Expected Behavior Android should just work like it does on iOS.
Actual Behavior Using no tls feature or "default-tls" or "rustls-tls" as reqwest features:
java.lang.UnsatisfiedLinkError: Unable to load library 'rustcore':
dlopen failed: cannot locate symbol "SSL_do_handshake" referenced by "/data/app/~~jBO-LA02dhvPb-R3c4eRgw==/dev.ryk.rustandroid-0jMgQkCi7UfLCOJEc3R4bw==/base.apk!/lib/arm64-v8a/librustcore.so"...
...
Native library (android-aarch64/librustcore.so) not found in resource path (.)
Using "native-tls" in reqwest feature:
java.lang.UnsatisfiedLinkError: Unable to load library 'rustcore':
dlopen failed: cannot locate symbol "BIO_meth_new" referenced by "/data/app/~~B-NPyDxI9tcSIpM8hLlzPQ==/dev.ryk.rustandroid-wKpl05lBlHfXOhfOAT9hRA==/base.apk!/lib/arm64-v8a/librustcore.so"...
...
Native library (android-aarch64/librustcore.so) not found in resource path (.)
Tried
- Installed openSSL 3 and 3.5 using homebrew, set paths to:
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig:$PKG_CONFIG_PATH"
export OPENSSL_INCLUDE_DIR="/opt/homebrew/opt/openssl@3/include"
export OPENSSL_LIB_DIR="/opt/homebrew/opt/openssl@3/lib"
export OPENSSL_DIR="/opt/homebrew/opt/openssl@3"