seanmonstar / reqwest

An easy and powerful Rust HTTP Client
https://docs.rs/reqwest
Apache License 2.0
9.7k stars 1.09k forks source link

0.12.5 and 0.12.7 can not working on android #2401

Open monotone opened 3 weeks ago

monotone commented 3 weeks ago

I am use tauri2 to run a very easy app on a android emulator, but I found when I use reqwest v0.12.5 or v0.12.7, my app will keep stopping.

if I change reqwest to v0.11.27, it will works well.

I am a new learner for rust and android, i don't known how to provide more detail error info.

seanmonstar commented 3 weeks ago

It could be subtle changes in how TLS works on Android. We do have an Android job in CI checking it compiles, but we can't compile test it with all possible versions of Android.

Most often, the problem is related to using OpenSSL on Android. Some fix that by using the native-tls-vendored feature. Others choose to make use of rustls-tls, and set default-features = false to disable native-tls (OpenSSL).

monotone commented 3 weeks ago

It could be subtle changes in how TLS works on Android. We do have an Android job in CI checking it compiles, but we can't compile test it with all possible versions of Android.

Most often, the problem is related to using OpenSSL on Android. Some fix that by using the native-tls-vendored feature. Others choose to make use of rustls-tls, and set default-features = false to disable native-tls (OpenSSL).

yes, I only try it in my Pixel 6 API 31(android 12) arm64, and it not works.

when add native-tls-vendored feature and run cargo tauri android dev, i got error:

 /bin/sh: aarch64-linux-android-ranlib: command not found
  make: *** [install_dev] Error 127
  thread 'main' panicked at /Users/xxx/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/openssl-src-300.3.1+3.3.1/src/lib.rs:621:9:

  Error installing OpenSSL:
      Command: cd "{{myproject dir}}/src-tauri/target/aarch64-linux-android/debug/build/openssl-sys-63f364135396933f/out/openssl-build/build/src" && "make" "install_dev"
      Exit status: exit status: 2

when set native-tls = { version = "0.2", default-features = false } reqwest = { version = "0.12.7" }, and run cargo tauri android dev, i got error:

--------- beginning of crash
08-24 21:19:27.801  5543  5543 E AndroidRuntime: FATAL EXCEPTION: main
08-24 21:19:27.801  5543  5543 E AndroidRuntime: Process: com.tauri.hp, PID: 5543
08-24 21:19:27.801  5543  5543 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "SSL_do_handshake" referenced by "/data/app/~~cSNjpBzzKjFBaLrPSqZWlw==/com.tauri.hp-QybI8jXyuUn5ZtcpI1Mjgw==/base.apk!/lib/arm64-v8a/libhp_lib.so"...
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at java.lang.Runtime.loadLibrary0(Runtime.java:998)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at java.lang.System.loadLibrary(System.java:1656)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at com.tauri.hp.WryActivity.<clinit>(WryActivity.kt:119)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at java.lang.Class.newInstance(Native Method)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.app.Instrumentation.newActivity(Instrumentation.java:1273)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3532)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.os.Looper.loopOnce(Looper.java:201)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:288)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:7839)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
08-24 21:19:27.801  5543  5543 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)