DioxusLabs/dioxus · error
Failed to find main symbol
Error message
Failed to find main symbol
What it means
On mobile, the desktop crate's injected root tried to locate the app's C entry point via dlsym for both "main" and "_main" and both lookups returned null. Without the main symbol pointer, the mobile runtime cannot hand off execution to the user's app.
Source
Thrown at packages/desktop/src/mobile.rs:77
fn stop_unwind<F: FnOnce() -> T, T>(f: F) -> T {
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)) {
Ok(t) => t,
Err(err) => {
eprintln!("attempt to unwind out of `rust` with err: {:?}", err);
std::process::abort()
}
}
}
stop_unwind(|| unsafe {
let mut main_fn_ptr = libc::dlsym(libc::RTLD_DEFAULT, b"main\0".as_ptr() as _);
if main_fn_ptr.is_null() {
main_fn_ptr = libc::dlsym(libc::RTLD_DEFAULT, b"_main\0".as_ptr() as _);
}
if main_fn_ptr.is_null() {
panic!("Failed to find main symbol");
}
// Set the env vars that rust code might expect, passed off to us by the android app
// Doing this before main emulates the behavior of a regular executable
if cfg!(target_os = "android") && cfg!(debug_assertions) {
// Load the env file from the session cache if we're in debug mode and on android
//
// This is a slightly hacky way of being able to use std::env::var code in android apps without
// going through their custom java-based system.
let env_file = dioxus_cli_config::android_session_cache_dir().join(".env");
if let Ok(env_file) = std::fs::read_to_string(&env_file) {
for line in env_file.lines() {
if let Some((key, value)) = line.trim().split_once('=') {
std::env::set_var(key, value);
}
}
}
}View on GitHub (pinned to 24f6a829df)
Solutions
- The mobile binary has no main symbol to call. Ensure the app exposes a main entry point and the mobile target links it correctly.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at packages/desktop/src/mobile.rs:77 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23).
Data as JSON: /api/errors/5ddf133578e28678.
Report an issue: GitHub.