#Running existing v1 app on v2 android, also file dialogs in v2

27 messages · Page 1 of 1 (latest)

sick tusk
#

Hi, I'm trying to run an existing v1 Tauri app on android using the v2 CLI. I've changed the versions of tauri and tauri-build in src-tauri/Cargo.toml to 2.0.0-alpha and upgraded tauri-cli to 2.0..0-alpha.14. I've run cargo tauri android init successfully, but when I try to run cargo tauri android build or cargo tauri android dev, I get this error:

error: no library targets found in package `app`
       Error `Failed to run `cargo build`: command ["cargo", "build", "--package", "app", "--manifest-path", "/home/dacid44/Documents/Rust/d4ft4/d4ft4-gui/src-tauri/Cargo.toml", "--target", "aarch64-linux-android", "--lib", "--release"] exited with code 101

It looks like it's expecting my project to be a library instead of a binary. Running cargo tauri dev as normal works fine, though. Do I need to migrate my app to v2 somehow? Is there a migration guide somewhere? All the tutorials I've found for Tauri v2 have assumed you're creating a new app from scratch.

As a secondary issue, do the file open and save dialogs exist in Tauri v2? How do I use them, at least on desktop? I was told by the Tauri CLI that the allowlist option in the config is no longer allowed, and that the feature flags needed to be removed from the Cargo.toml I'd understand if the mobile versions weren't quite working yet, though I'd assume at least the open dialog would open the android file picker (once it's implemented).

Thanks!

#

Running existing v1 app on v2 android, also file dialogs in v2

sick tusk
#

I've created a dummy lib.rs and the associated entries in [lib] in the cargo.toml, and it starts building, but I finally get a gradle error (attached as a file).

#

I'm not sure that the dummy lib.rs will even work, since it doesn't seem like it's going to build anything in main.rs, which is where all of my tauri commands are.

rose verge
sick copper
#

You can also running pnpm create tauri-app --alpha and choose using mobile feature to see how template makes it works

sick tusk
#

Got it working! Key takeaways for anyone else who has this come up as well:

  • Rename your main.rs to lib.rs
  • Add this section in your Cargo.toml:
[lib]
name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
  • Change your fn main() to pub fn run()
  • add #[cfg_attr(mobile, tauri::mobile_entry_point)] to the line above pub fn run()
  • Add a new main.rs that looks like this (and you can remove the windows_subsystem = "windows" lines from the top of your lib.rs):
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

fn main() {
    app_lib::run();
}
sick tusk
idle heart
#

So, I stumbled upon this same error as well and I did as you described, but my UI is unresponsive now. The Window is opened up but nothing is happening, neither links or buttons. Did you encounter this as well?

#

I get this error when I click something/try to use the default example but it doesn't tell me very much, at least nothing I am understanding.

[Error] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'window.__TAURI__.tauri.invoke')
    (anonymous function) (tauri-leptos-test-ui-ebdb65714b88c8a7.js:271)
    <?>.wasm-function[tauri_leptos_test_ui::app::invoke::{{closure}}::h53b927996088ff1a]
    <?>.wasm-function[tauri_leptos_test_ui::app::App::__App::{{closure}}::{{closure}}::h23045c4fee69a418]
    <?>.wasm-function[wasm_bindgen_futures::task::singlethread::Task::run::hee18c8379032a47d]
    <?>.wasm-function[wasm_bindgen_futures::queue::QueueState::run_all::h484005b1e535a679]
    <?>.wasm-function[wasm_bindgen_futures::queue::Queue::new::{{closure}}::ha5cc4c5f887cc9fc]
    <?>.wasm-function[<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hf4be5a868c630261]
    __wbg_adapter_28 (tauri-leptos-test-ui-ebdb65714b88c8a7.js:216:135)
    real (tauri-leptos-test-ui-ebdb65714b88c8a7.js:193)
rose verge
hollow parcel
#

the CTA templates may have not been updated yet, can you replace window.__TAURI__.tauri.invoke with window.__TAURI__.primitives.invoke and try again?

#

gosh i hate the new name, i need 3 tries to correctly type it 🙃

idle heart
#

Where would I find an example with the alpha? I couldn't seem to find one yesterday

hollow parcel
#

for leptos (or any rust frontend framework)? Nowhere really

#

you can however do npm create tauri-app --alpha, select leptos and again change tauri to primitives in app.rs and then it should work

idle heart
#

I keep testing everything with svelte in parallel and that's working neither.

hollow parcel
#

did you try removing all plugins from the template?

#

We're still updating them

#

(the release pipeline is running right now)

idle heart
#

And also:

Okt 23 18:02:30 MAA01103 kernel: Out of memory: Killed process 547360 (rust-analyzer) total-vm:3311152kB, anon-rss:2290860kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:4796kB oom_score_adj:200
Okt 23 18:02:30 MAA01103 systemd[1]: [email protected]: A process of this unit has been killed by the OOM killer.
Okt 23 18:02:30 MAA01103 systemd[898]: app-org.kde.konsole-a1f838a6d5494335bc4f0b2cd1cfe5ef.scope: A process of this unit has been killed by the OOM killer.
Okt 23 18:02:30 MAA01103 systemd[1]: Started Process Core Dump (PID 557804/UID 0).
Okt 23 18:02:31 MAA01103 systemd-coredump[557807]: [🡕] Process 547139 (code) of user 1000 dumped core.

^ lol

hollow parcel
#

ouch kkushLUL

idle heart