dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Openssl error on Android

Open cbdefontenay opened this issue 1 year ago • 16 comments

Problem

When running a new dioxus app for mobile devices with Barebones or Jumpstart from the cli, everything works fine on the android emulator at first, the app is launching. But as soon as the crate reqwest is added and used, like in the HotDog tutorial, I get an Openssl error (and perl by extention).

So I saw there were already an issue like this reported a few month ago, but I thought because it happened not only on my computer but also on two other Windows OS based computers, (even after following all the steps of the documentation even this discussion), this might be an issue. So I hope I am in the right place and this is really an issue/bug and not something I did wrong.

Steps To Reproduce

Steps to reproduce the behavior:

  • dx new hotdog
  • Default platform web/fullstack/server (like in the Hotdog tutorial) but trying to serve on Android.
  • dx serve --platform android

Expected behavior

The expected behaviour for the HotDog tutorial at least or any other project using reqwest and serving Android would be that the app launches and runs.

Screenshots The error is the following:

22:15:02 [cargo] error: failed to run custom build command for `openssl-sys v0.9.104`
22:15:02 [cargo] Caused by:
22:15:02 [cargo]   process didn't exit successfully: `C:\Users\[name]\Documents\Rust\hotdog\target\android-dev\build\openssl-sys-349e62533ee4b264\build-script-main` (exit code: 1)  
22:15:02 [cargo]   --- stdout
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(osslconf, values("OPENSSL_NO_OCB", "OPENSSL_NO_SM4", "OPENSSL_NO_SEED", "OPENSSL_NO_CHACHA", "OPENSSL_NO_CAST", "OPENSSL_NO_IDEA", "OPENSSL_NO_CAMELLIA", "OPENSSL_NO_RC4", "OPENSSL_NO_BF", "OPENSSL_NO_PSK", "OPENSSL_NO_DEPRECATED_3_0", "OPENSSL_NO_SCRYPT", "OPENSSL_NO_SM3", "OPENSSL_NO_RMD160", "OPENSSL_NO_EC2M", "OPENSSL_NO_OCSP", "OPENSSL_NO_CMS", "OPENSSL_NO_COMP", "OPENSSL_NO_SOCK", "OPENSSL_NO_STDIO", "OPENSSL_NO_EC", "OPENSSL_NO_SSL3_METHOD", "OPENSSL_NO_KRB5", "OPENSSL_NO_TLSEXT", "OPENSSL_NO_SRP", "OPENSSL_NO_RFC3779", "OPENSSL_NO_SHA", "OPENSSL_NO_NEXTPROTONEG", "OPENSSL_NO_ENGINE", "OPENSSL_NO_BUF_FREELISTS"))
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(openssl)                                                                                                                               
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(boringssl)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl250)                                                                                                                           
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl251)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl252)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl261)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl270)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl271)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl273)                                                                                                                           
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl280)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl281)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl291)                                                                                                                           
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl310)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl321)                                                                                                                           
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl332)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl340)                                                                                                                           
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl350)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl360)                                                                                                                           
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl361)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl370)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl380)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl381)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl382)                                                                                                                           
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl390)                                                                                                                           
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(libressl400)                                                                                                                           
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl101)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl102)                                                                                                                               
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl102f)                                                                                                                              
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl102h)                                                                                                                              
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl110)                                                                                                                               
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl110f)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl110g)                                                                                                                              
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl110h)                                                                                                                              
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl111)                                                                                                                               
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl111b)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl111c)                                                                                                                              
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl111d)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl300)                                                                                                                               
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl310)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl320)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl330)
22:15:02 [cargo]   cargo:rustc-check-cfg=cfg(ossl340)                                                                                                                               
22:15:02 [cargo]   cargo:rerun-if-env-changed=X86_64_LINUX_ANDROID_OPENSSL_NO_VENDOR                                                                                                
22:15:02 [cargo]   X86_64_LINUX_ANDROID_OPENSSL_NO_VENDOR unset                                                                                                                     
22:15:02 [cargo]   cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR                                                                                                                     
22:15:02 [cargo]   OPENSSL_NO_VENDOR unset                                                                                                                                          
22:15:02 [cargo]   cargo:rerun-if-env-changed=X86_64_LINUX_ANDROID_OPENSSL_CONFIG_DIR                                                                                               
22:15:02 [cargo]   X86_64_LINUX_ANDROID_OPENSSL_CONFIG_DIR unset                                                                                                                    
22:15:02 [cargo]   cargo:rerun-if-env-changed=OPENSSL_CONFIG_DIR                                                                                                                    
22:15:02 [cargo]   OPENSSL_CONFIG_DIR unset                                                                                                                                         
22:15:02 [cargo]   TARGET = Some(x86_64-linux-android)
22:15:02 [cargo]   OUT_DIR = Some(C:\Users\[name]\Documents\Rust\hotdog\target\x86_64-linux-android\android-dev\build\openssl-sys-56e305dc28bcc577\out)                              
22:15:02 [cargo]   cargo:rerun-if-env-changed=CC_x86_64-linux-android                                                                                                               
22:15:02 [cargo]   CC_x86_64-linux-android = None                                                                                                                                   
22:15:02 [cargo]   cargo:rerun-if-env-changed=CC_x86_64_linux_android                                                                                                               
22:15:02 [cargo]   CC_x86_64_linux_android = None                                                                                                                                   
22:15:02 [cargo]   cargo:rerun-if-env-changed=TARGET_CC                                                                                                                             
22:15:02 [cargo]   TARGET_CC = Some(C:\Users\[name]\AppData\Local\Android\Sdk\ndk\28.0.12674087\toolchains\llvm\prebuilt\windows-x86_64\bin\clang)                                   
22:15:02 [cargo]   cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
22:15:02 [cargo]   CC_KNOWN_WRAPPER_CUSTOM = None                                                                                                                                   
22:15:02 [cargo]   RUSTC_WRAPPER = None                                                                                                                                             
22:15:02 [cargo]   cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT                                                                                                                
22:15:02 [cargo]   cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS                                                                                                                  
22:15:02 [cargo]   CRATE_CC_NO_DEFAULTS = None
22:15:02 [cargo]   DEBUG = Some(true)                                                                                                                                               
22:15:02 [cargo]   cargo:rerun-if-env-changed=CFLAGS_x86_64-linux-android                                                                                                           
22:15:02 [cargo]   CFLAGS_x86_64-linux-android = None
22:15:02 [cargo]   cargo:rerun-if-env-changed=CFLAGS_x86_64_linux_android
22:15:02 [cargo]   CFLAGS_x86_64_linux_android = None                                                                                                                               
22:15:02 [cargo]   cargo:rerun-if-env-changed=TARGET_CFLAGS                                                                                                                         
22:15:02 [cargo]   TARGET_CFLAGS = None                                                                                                                                             
22:15:02 [cargo]   cargo:rerun-if-env-changed=CFLAGS                                                                                                                                
22:15:02 [cargo]   CFLAGS = None                                                                                                                                                    
22:15:02 [cargo]   CARGO_ENCODED_RUSTFLAGS = Some(-Clinker=C:\Users\[name]\.cargo\bin\dx.exe-Clink-arg=-landroid-Clink-arg=-llog-Clink-arg=-lOpenSLES-Clink-arg=-Wl,--export-dynamic)
22:15:02 [cargo]   cargo:rerun-if-env-changed=AR_x86_64-linux-android                                                                                                               
22:15:02 [cargo]   AR_x86_64-linux-android = None                                                                                                                                   
22:15:02 [cargo]   cargo:rerun-if-env-changed=AR_x86_64_linux_android                                                                                                               
22:15:02 [cargo]   AR_x86_64_linux_android = None
22:15:02 [cargo]   cargo:rerun-if-env-changed=TARGET_AR
22:15:02 [cargo]   TARGET_AR = Some(C:\Users\[name]\AppData\Local\Android\Sdk\ndk\28.0.12674087\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-ar)                                 
22:15:02 [cargo]   cargo:rerun-if-env-changed=ARFLAGS_x86_64-linux-android                                                                                                          
22:15:02 [cargo]   ARFLAGS_x86_64-linux-android = None
22:15:02 [cargo]   cargo:rerun-if-env-changed=ARFLAGS_x86_64_linux_android                                                                                                          
22:15:02 [cargo]   ARFLAGS_x86_64_linux_android = None                                                                                                                              
22:15:02 [cargo]   cargo:rerun-if-env-changed=TARGET_ARFLAGS                                                                                                                        
22:15:02 [cargo]   TARGET_ARFLAGS = None                                                                                                                                            
22:15:02 [cargo]   cargo:rerun-if-env-changed=ARFLAGS                                                                                                                               
22:15:02 [cargo]   ARFLAGS = None
22:15:02 [cargo]   cargo:rerun-if-env-changed=RANLIB_x86_64-linux-android                                                                                                           
22:15:02 [cargo]   RANLIB_x86_64-linux-android = None                                                                                                                               
22:15:02 [cargo]   cargo:rerun-if-env-changed=RANLIB_x86_64_linux_android                                                                                                           
22:15:02 [cargo]   RANLIB_x86_64_linux_android = None                                                                                                                               
22:15:02 [cargo]   cargo:rerun-if-env-changed=TARGET_RANLIB
22:15:02 [cargo]   TARGET_RANLIB = None                                                                                                                                             
22:15:02 [cargo]   cargo:rerun-if-env-changed=RANLIB                                                                                                                                
22:15:02 [cargo]   RANLIB = None                                                                                                                                                    
22:15:02 [cargo]   cargo:rerun-if-env-changed=RANLIBFLAGS_x86_64-linux-android                                                                                                      
22:15:02 [cargo]   RANLIBFLAGS_x86_64-linux-android = None                                                                                                                          
22:15:02 [cargo]   cargo:rerun-if-env-changed=RANLIBFLAGS_x86_64_linux_android                                                                                                      
22:15:02 [cargo]   RANLIBFLAGS_x86_64_linux_android = None                                                                                                                          
22:15:02 [cargo]   cargo:rerun-if-env-changed=TARGET_RANLIBFLAGS                                                                                                                    
22:15:02 [cargo]   TARGET_RANLIBFLAGS = None
22:15:02 [cargo]   cargo:rerun-if-env-changed=RANLIBFLAGS
22:15:02 [cargo]   RANLIBFLAGS = None                                                                                                                                               
22:15:02 [cargo]   running "perl" "./Configure" "--prefix=C:/Users/[name]/Documents/Rust/hotdog/target/x86_64-linux-android/android-dev/build/openssl-sys-56e305dc28bcc577/out/openssl-build/install" "--openssldir=/usr/local/ssl" "no-shared" "no-module" "no-ssl3" "no-tests" "no-comp" "no-zlib" "no-zlib-dynamic" "--libdir=lib" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-stdio" "linux-x86_64" "-O2" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "--target=x86_64-linux-android"
22:15:03 [cargo]   cargo:warning=configuring OpenSSL build: 'perl' reported failure with exit code: 2                                                                               
22:15:03 [cargo]   cargo:warning=openssl-src: failed to build OpenSSL from source                                                                                                   
22:15:03 [cargo]   --- stderr                                                                                                                                                       
22:15:03 [cargo]   Can't locate Locale/Maketext/Simple.pm in @INC (you may need to install the Locale::Maketext::Simple module) (@INC entries checked: /c/Users/[name]/Documents/Rust/hotdog/target/x86_64-linux-android/android-dev/build/openssl-sys-56e305dc28bcc577/out/openssl-build/build/src/util/perl /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl /c/Users/cbdef/Documents/Rust/hotdog/target/x86_64-linux-android/android-dev/build/openssl-sys-56e305dc28bcc577/out/openssl-build/build/src/external/perl/Text-Template-1.56/lib) at /usr/share/perl5/core_perl/Params/Check.pm line 6.                            
22:15:03 [cargo]   BEGIN failed--compilation aborted at /usr/share/perl5/core_perl/Params/Check.pm line 6.                                                                          
22:15:03 [cargo]   Compilation failed in require at /usr/share/perl5/core_perl/IPC/Cmd.pm line 59.                                                                                  
22:15:03 [cargo]   BEGIN failed--compilation aborted at /usr/share/perl5/core_perl/IPC/Cmd.pm line 59.
22:15:03 [cargo]   Compilation failed in require at /c/Users/[name]/Documents/Rust/hotdog/target/x86_64-linux-android/android-dev/build/openssl-sys-56e305dc28bcc577/out/openssl-build/build/src/util/perl/OpenSSL/config.pm line 19.                                                                                                                                    
22:15:03 [cargo]   BEGIN failed--compilation aborted at /c/Users/[name]/Documents/Rust/hotdog/target/x86_64-linux-android/android-dev/build/openssl-sys-56e305dc28bcc577/out/openssl-build/build/src/util/perl/OpenSSL/config.pm line 19.                                                                                                                                
22:15:03 [cargo]   Compilation failed in require at ./Configure line 23.                                                                                                            
22:15:03 [cargo]   BEGIN failed--compilation aborted at ./Configure line 23.                                                                                                        
22:15:03 [cargo]   Error configuring OpenSSL build:                                                                                                                                 
22:15:03 [cargo]       'perl' reported failure with exit code: 2
22:15:03 [cargo]       Command failed: "perl" "./Configure" "--prefix=C:/Users/[name]/Documents/Rust/hotdog/target/x86_64-linux-android/android-dev/build/openssl-sys-56e305dc28bcc577/out/openssl-build/install" "--openssldir=/usr/local/ssl" "no-shared" "no-module" "no-ssl3" "no-tests" "no-comp" "no-zlib" "no-zlib-dynamic" "--libdir=lib" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-stdio" "linux-x86_64" "-O2" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "--target=x86_64-linux-android"
22:15:03 [cargo] warning: build failed, waiting for other jobs to finish...
22:15:06 [dev] Build failed: Other(Cargo build failed, signaled by the compiler. Toggle tracing mode (press `t`) for more information.)

My Cargo.toml does include:

[target.'cfg(target_os = "android")'.dependencies]
openssl = { version = "0.10", features = ["vendored"] }

Environment:

  • Dioxus version: 0.6
  • Rust version: rustup 1.27.1 (54dd3d00f 2024-04-24) info: This is the version for the rustup toolchain manager, not the rustc compiler. info: The currently active `rustc` version is `rustc 1.83.0 (90b35a623 2024-11-26)
  • OS info: Windows
  • App platform: Android

cbdefontenay avatar Jan 07 '25 21:01 cbdefontenay

if using reqwest, you can disable default features and enable rustls-tls instead to use rustls instead of openssl.

reqwest = { version = "0.12.12", default-features = false, features = [
    "rustls-tls",
    "charset",
    "http2",
    "macos-system-configuration",
] }

sehnryr avatar Jan 13 '25 09:01 sehnryr

I tried but I still got the openssl error. So I think it really is a bug.

cbdefontenay avatar Jan 14 '25 07:01 cbdefontenay

@cbdefontenay I believe openssl cannot be compiled on android target. You should use rustls instead.

Check which dependencies uses openssl in your Cargo.lock file.

sehnryr avatar Jan 14 '25 08:01 sehnryr

Interesting, I tried by deleting the

[target.'cfg(target_os = "android")'.dependencies]
openssl = { version = "0.10", features = ["vendored"] }

and it worked then fine on Android. So merci beaucoup for the help. But I guess Dioxus aims at one Code for multiple platforms, meaning this kind of potential openssl error still has to go away in next versions.

cbdefontenay avatar Jan 14 '25 08:01 cbdefontenay

I tried this and then the app builds for Android and deploys to the simulator. However, it keeps shutting down every time I open the app. It briefly displays the app and then the app closes down. Also, on the server side, it says it can't forward to port 8080 as it should.

gbutler69 avatar Mar 12 '25 20:03 gbutler69

I also had the same issue, I am using Rustrover from Jetbrains, and I had to quit it and the app (as well as deleting the app from the simulator), restart the IDE and finally restart the project as wel, then it worked fine for me.

cbdefontenay avatar Mar 12 '25 21:03 cbdefontenay

@cbdefontenay - Hey there! I'm using the standard Google Android Studio on Ubuntu 24.10. I have reqwest configured to use the "rustls-tls" feature and it builds and deploys successfully. When it attempts to make an HTTPS call in the App, the App crashes (with no indication as to why that I'm able to access). I know it is the call to HTTPS that is the issue. If I completely disable SSL by not enabling either the rustls or the openssl feature, then I get an error saying that HTTPS is not supported. It can however make calls to HTTP URL's just fine.

You said that the rustls-tls option was working for you. Is that correct? Could you give me the details as to what version of everything you are using so I can try to replicate it working vs not working?

gbutler69 avatar Mar 14 '25 23:03 gbutler69

@gbutler69 Hej! So I will reply here. So I guess it has nothing to do with Ubuntu or Android Studio, but the last time after spending days trying to resolve the problem, I tried this and it worked:

Step 1: I cloned the hotdod project from here. (But also works if you just followed the "hotdog" tutorial from the Dioxus website.

Step 2: I changed the Cargo.toml to the following:

[package]
name = "hot_dog"
version = "0.1.0"
authors = ["Dioxus Labs"]
edition = "2021"

[dependencies]
dioxus = { version = "0.6.3", features = ["fullstack", "router"] }
reqwest = { version = "0.12.14", default-features = false, features = [
    "rustls-tls",
    "charset",
    "http2",
    "macos-system-configuration",
    "json"
] }
serde = { version = "1.0.219", features = ["derive"] }
rusqlite = { version = "0.34.0", features = ["bundled", "unlock_notify"], optional = true }

[features]
default = ["web", "server"]
web = ["dioxus/web"]
desktop = ["dioxus/desktop"]
mobile = ["dioxus/mobile"]
server = ["dioxus/server", "dep:rusqlite"]

[profile]
[profile.wasm-dev]
inherits = "dev"
opt-level = 1

[profile.server-dev]
inherits = "dev"

[profile.android-dev]
inherits = "dev"

Step 3: I launched the app with dx serve --platform android. (I just retried on my physical device to be sure, and it worked fine.

As you said, the SQLite database is not working at all by me, and I really do not know why, I see the dogs, I can skip to the next one and it works fine, but storing them just freezes the app, it is not working at all, and I still don't know how to solve this... Maybe the rustls-tls options are not compatible with Android... I don't know, but as you see in the updated Cargo.toml, the rusqlite package had to get the features = ["bundled", "unlock_notify"] features, else the app throws error while building or launching. Maybe that was that your problem.

Let me know if that worked. by me at least it solved the OpenSSl and server problem and SQLite, even if that last one does not work, at least I can visualize the app.

cbdefontenay avatar Mar 15 '25 08:03 cbdefontenay

As you said, the SQLite database is not working at all by me, and I really do not know why, ... but storing them just freezes the app, it is not working at all, and I still don't know how to solve this...

Interesting. The SQLite stuff is working absolutely fine for me. I have the following for the DogView:

#[component]
pub fn DogView() -> Element {
    let mut img_src = use_resource(|| async move {
        match reqwest::get("https://dog.ceo/api/breeds/image/random").await {
            Ok(response) => match response.json::<DogApi>().await {
                Ok(api_response) => (api_response.message, "".to_owned()),
                Err(err) => (
                    "".to_owned(),
                    format!("Unable to parse API response: {err:?}"),
                ),
            },
            Err(err) => ("".to_owned(), format!("Unable to retrieve photo: {err:?}")),
        }
    });
    rsx! {
        div { id: "dogview",
            "{img_src.cloned().unwrap_or_default().1}"
            if !img_src.cloned().unwrap_or_default().0.is_empty() {
                img { src: img_src.cloned().unwrap_or_default().0 }
            }
        }
        div { id: "buttons",
            button { onclick: move |_| img_src.restart(), id: "skip", "👎 Skip" }
            button {
                onclick: move |_| async move {
                    let current = img_src.cloned().unwrap_or_default();
                    img_src.restart();
                    if !current.0.is_empty() {
                        _ = crate::backend::save_dog(current.0).await;
                    }
                },
                id: "save",
                "♥️ Like"
            }
        }
    }
}

and the following for the Favorites View:

#[component]
pub fn Favorites() -> Element {
    let mut favorites = use_resource(crate::backend::list_dogs);
    let favorites_signal = favorites.suspend()?;
    rsx! {
        div { id: "favorites",
            div { id: "favorites-container",
                for (id , url) in favorites_signal().unwrap() {
                    div { key: id, class: "favorite-dog",
                        img { src: "{url}" }
                        div { class: "favorite-dog",
                            button {
                                id: "delete",
                                onclick: move |_| async move {
                                    _ = crate::backend::delete_dog(id).await;
                                    favorites.restart();
                                },
                                "❌"
                            }
                        }
                    }
                }
            }
        }
    }
}

Also, on the server side I have the following:

use dioxus::prelude::*;

#[server]
pub async fn save_dog(image: String) -> Result<(), ServerFnError> {
    DB.with(|f| f.execute("INSERT INTO dogs (url) VALUES (?1)", [&image]))?;
    Ok(())
}

#[server]
pub async fn delete_dog(id: usize) -> Result<(), ServerFnError> {
    DB.with(|f| f.execute("delete from dogs where id = (?1)", [&id]))?;
    Ok(())
}

#[cfg(feature = "server")]
thread_local! {
    pub static DB: rusqlite::Connection = {
        let conn = rusqlite::Connection::open("hotdog.db").expect("Failed to open database");
        conn.execute_batch(
            "CREATE TABLE IF NOT EXISTS dogs (
                id INTEGER PRIMARY KEY,
                url TEXT NOT NULL
            );",
        ).unwrap();
        conn
    };
}

#[server]
pub async fn list_dogs() -> Result<Vec<(usize, String)>, ServerFnError> {
    let dogs = DB.with(|f| {
        f.prepare("SELECT id, url FROM dogs ORDER BY id DESC LIMIT 100")
            .unwrap()
            .query_map([], |row| Ok((row.get(0)?, row.get(1)?)))
            .unwrap()
            .map(|r| r.unwrap())
            .collect()
    });
    Ok(dogs)
}

Everything related to seeing the list of favorites and deleting dogs works (in Android as well as Desktop and Web). However, for me, the "reqwest" to the DogApi doesn't work and crashes the App. I've definitely narrowed it down to that. That is why my DogView has all the matching and error handling so I could narrow down the issue. NOTE: Everything works for Desktop and Web options.

Maybe the rustls-tls options are not compatible with Android...

Since viewing the Dogs and skipping to the next works for you, I'd say rustls-tls is working 100% correctly for you (unlike for me).

I don't know, but as you see in the updated Cargo.toml, the rusqlite package had to get the features = ["bundled", "unlock_notify"] features, else the app throws error while building or launching.

I'm actually not having any issues with "rustqlite". NOTE: That is only used on the server side and not on the client. I can view the favorites and delete dogs from the favorites just fine.

Maybe that was that your problem.

I have all the same Cargo.toml options related to "rustqlite" and "rustls" that you have, so I'm not really sure why "reqwest" is causing the client to crash for me on Android while it works for you. Also, I can retrieve and view the favorites and delete dogs just fine so rustqlite is working 100% correctly for me.

Hopefully when you look at my code above, you'll see something that will help you get your rustqlite working on your system.

Here is my Cargo.toml as well:

[package]
name = "hot-dog"
version = "0.1.0"
authors = ["Gerald E. Butler <[email protected]>"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
dioxus = { version = "0.6", features = ["fullstack", "router"] }
reqwest = { version = "0.12", default-features = false, features = [
    "charset",
    "http2",
    "json",
    "rustls-tls",
] }
rusqlite = { version = "0.34", optional = true }
serde = { version = "1.0", features = ["derive"] }

# [target.'cfg(target_os = "android")'.dependencies]
# openssl = { version = "0.10", features = ["vendored"] }

# [target.'cfg(target_os = "android")'.dependencies]
# rustls = { version = "0.23", default-features = false, features = [
#     "aws-lc-rs",
# ] }


[features]
default = []
web = ["dioxus/web"]
desktop = ["dioxus/desktop"]
mobile = ["dioxus/mobile"]
server = ["dioxus/server", "dep:rusqlite"]

[profile]

[profile.wasm-dev]
inherits = "dev"
opt-level = 1

[profile.server-dev]
inherits = "dev"

[profile.android-dev]
inherits = "dev"

gbutler69 avatar Mar 15 '25 08:03 gbutler69

I tried this and then the app builds for Android and deploys to the simulator. However, it keeps shutting down every time I open the app. It briefly displays the app and then the app closes down. Also, on the server side, it says it can't forward to port 8080 as it should.

@gbutler69 - the cargo.toml you posted was super helpful. Did you manage to resolve your port forwarding issue on android?

I'm also getting this when I try to serve to Android:

17:24:42 [dev] Build completed successfully in 2697ms, launching app! 💫
17:24:42 [dev] failed to forward port 8080: program not found      

The "program not found" makes me wonder if there's something like a connector needed to talk to ADB.

domdelorenzo avatar Mar 25 '25 22:03 domdelorenzo

@gbutler69 I just tried the app with your code, and at my surprise I can now store a dog without freezing the app, but I still cannot access the page where the stored dogs are listed. I might review my code to find where the error lies...

Anyway, thanks for the help and the sharing. I hope you could fix your error as wel since last time.

cbdefontenay avatar Mar 27 '25 22:03 cbdefontenay

Did you manage to resolve your port forwarding issue on android?

No, I didn't, but I don't think that is actually an issue. I'm able to view the list of favorites and delete favorites just fine. I only have issues with retrieving the Dogs through https from the public end-point.

gbutler69 avatar Mar 28 '25 08:03 gbutler69

I hope you could fix your error as wel since last time.

Unfortunately, I've still been unable to get the page for selecting favorites working on the Android version.

Are you using Rustls or OpenSSL? @cbdefontenay

gbutler69 avatar Mar 28 '25 08:03 gbutler69

The "program not found" makes me wonder if there's something like a connector needed to talk to ADB.

@domdelorenzo - I'm pretty sure that isn't the issue.

Are you using rustls or openssl?

gbutler69 avatar Mar 28 '25 08:03 gbutler69

Are you using rustls or openssl?

@gbutler69 I'm using rustls in the reqwest features. It won't compile to Android if I try to use openssl.

domdelorenzo avatar Apr 02 '25 16:04 domdelorenzo

I hope you could fix your error as wel since last time.

Unfortunately, I've still been unable to get the page for selecting favorites working on the Android version.

Are you using Rustls or OpenSSL? @cbdefontenay

@gbutler69 I am using Rustls, but I've tried it with OenSSL too, but it was even worse.

cbdefontenay avatar Apr 03 '25 15:04 cbdefontenay

I'm experiencing a similar issue when I run my app on a container with no openssl since the fullstack feature have this dependency tree server_fn > reqwest, we are not able to avoid native-tls and use rust-tls instead.

 error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory

xsoheilalizadeh avatar Jul 06 '25 12:07 xsoheilalizadeh

We vendor openssl on android now by default. There's a new cargo feature on desktop that let's you disable this in lieu of rustls, but I think vendoring is the right answer for android and cross compiling.

https://github.com/DioxusLabs/dioxus/pull/4376

jkelleyrtp avatar Jul 15 '25 21:07 jkelleyrtp