tauri: [bug] bundleresources is not working for Android

Describe the bug

It won’t bundle the resources specified in the bundleresources config for Android (yarn tauri android dev). Does this option apply to Android?

"bundle": {
    "resources": [
        "resources/*"
    ]
}

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22000 X64
    ✔ WebView2: 121.0.2277.128
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.71.0 (8ede3aae2 2023-07-12)
    ✔ cargo: 1.71.0 (cfd3bbd8f 2023-06-08)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 18.16.0
    - yarn: 1.22.19
    - npm: 9.5.1

[-] Packages
    - tauri [RUST]: 2.0.0-alpha.21
    - tauri-build [RUST]: 2.0.0-alpha.14
    - wry [RUST]: 0.35.2
    - tao [RUST]: 0.24.0
    - tauri-cli [RUST]: 1.3.1
    - @tauri-apps/api [NPM]: 2.0.0-alpha.13
    - @tauri-apps/cli [NPM]: 2.0.0-alpha.20

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 5
  • Comments: 25 (7 by maintainers)

Most upvoted comments

I think the official tauri FS plugin should really get improved in Rust side

If only we’d have unlimited time 😃)

We’d be very open to work together with the maintainer or anyone who’s interested to merge ideas of that plugin into the official one. Unfortunately we’ve seen time and time again that people rather do their own thing than contribute to existing projects. Which of course is fine but still sucks for us 😂

Thanks @FabianLars. This one is on my radar and if I’m blocked by it I may end up working on a PR.

Hardcoding the data in an array is not a solution for me, because I need GROUP BY queries. Hardcoding the 100k+ row SQLite database as a migration for an in-memory sqlite db is risky, seeing that many Android devices are not high-end, I really don’t want to rely on any computing power on the client side for Android. What if this fails for some users, while it being a paid app?

I understand that hardcoding resources is a good solution in many cases, but not for a database. Any major app that shows information that is not entered by the user and that doesn´t rely on some external server API really needs a database as a resource.

This bug is open for more than a year now and I am wondering as to why. Is this a really hard problem to solve or just has none of the developers working on Tauri had the time to look into this yet? Which I do understand for a FOSS project of course.

Don’t get me wrong, I think Tauri is a fantastic framework, I loved developing with it, but this is really a problem.

Ok, I finally solve this puzzle )

Apologies if I’m talking nonsense, as I’m new to Tauri.

In my use case, I made it work by using Tauri FS plugin instead of Rust’s std::fs.

Basically, taking the code given in the Embedding Additional Files section of the docs as an example, I’ve just replaced this line: let file = std::fs::File::open(&resource_path).unwrap();

With this one: let file = handle.fs().open(&resource_path).unwrap();

Reasoning: The source code on tauri-utils mentions in the comments that Android uses a special URI prefix that is resolved by the Tauri file system plugin "asset://localhost/"

So I suppose Tauri expect us to use handle.fs() instead of std::fs, although the documentation uses a std::fs (which works just fine on non-android environments).

Documentation and source code links: