@creative-account

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Tauri ビルドエラー

解決したいこと

Tauriで時計アプリを作成しています。
リリース用にビルドをしたいのですがビルドが通りません。
助けてください。

発生している問題・エラー

npm run tauri buildのエラー

error[E0786]: found invalid metadata files for crate `stellarclock_lib`
 --> src\main.rs:5:5
  |
5 |     stellarclock_lib::run()
  |     ^^^^^^^^^^^^^^^^
  |
  = note: corrupt metadata encountered in \\?\D:\mario\source\repos\StellarClock\src-tauri\target\release\deps\libstellarclock_lib.rlib

For more information about this error, try `rustc --explain E0786`.
error: could not compile `stellarclock` (bin "stellarclock") due to 1 previous error
failed to build app: failed to build app
       Error failed to build app: failed to build app

npm run tauri android buildのエラー

error: could not compile `stellarclock` (lib) due to 1 previous error
`Failed to run `cargo build`: command ["cargo", "build", "--package", "stellarclock", "--manifest-path", "D:\\mario\\source\\repos\\StellarClock\\src-tauri\\Cargo.toml", "--target", "armv7-linux-androideabi", "--features", "tauri/custom-protocol tauri/custom-protocol", "--lib", "--release"] exited with code 101
       Error `Failed to run `cargo build`: command ["cargo", "build", "--package", "stellarclock", "--manifest-path", "D:\\mario\\source\\repos\\StellarClock\\src-tauri\\Cargo.toml", "--target", "armv7-linux-androideabi", "--features", "tauri/custom-protocol tauri/custom-protocol", "--lib", "--release"] exited with code 101

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:rustBuildArmRelease'.
> Process 'command 'npm.cmd'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 27m 48s
Failed to assemble APK: command ["D:\\mario\\source\\repos\\StellarClock\\src-tauri\\gen/android\\gradlew.bat", "--project-dir", "D:\\mario\\source\\repos\\StellarClock\\src-tauri\\gen/android"] exited with code 1: command ["D:\\mario\\source\\repos\\StellarClock\\src-tauri\\gen/android\\gradlew.bat", "--project-dir", "D:\\mario\\source\\repos\\StellarClock\\src-tauri\\gen/android"] exited with code 1
       Error Failed to assemble APK: command ["D:\\mario\\source\\repos\\StellarClock\\src-tauri\\gen/android\\gradlew.bat", "--project-dir", "D:\\mario\\source\\repos\\StellarClock\\src-tauri\\gen/android"] exited with code 1: command ["D:\\mario\\source\\repos\\StellarClock\\src-tauri\\gen/android\\gradlew.bat", "--project-dir", "D:\\mario\\source\\repos\\StellarClock\\src-tauri\\gen/android"] exited with code 1

該当するソースコード

src-tauri/src/main.rs
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

fn main() {
    stellarclock_lib::run()
}
src-tauri/src/lib.rs
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_opener::init())
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
src-tauri/Cargo.toml
[package]
name = "stellarclock"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"

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

[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "stellarclock_lib"
crate-type = ["staticlib", "cdylib", "rlib"]

[build-dependencies]
tauri-build = { version = "2", features = [] }

[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"

自分で試したこと

  • src-tauri/targetの削除
  • cargo cleanの実行
  • プロジェクトを作成し直した直後でのビルド
    Rust関係のソースコードや設定は初期状態のままいじっていません。

環境

何故かWindows 10と表示されていますがWindows 11です。

$ npm run tauri info

> stellarclock@0.1.0 tauri
> tauri info


[✔] Environment
    - OS: Windows 10.0.26100 x86_64 (X64)
    ✔ WebView2: 138.0.3351.95
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.88.0 (6b00bc388 2025-06-23)
    ✔ cargo: 1.88.0 (873a06493 2025-05-10)
    ✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 23.8.0
    - npm: 11.4.2

[-] Packages
    - tauri 🦀: 2.6.2, (outdated, latest: 2.7.0)
    - tauri-build 🦀: 2.3.0, (outdated, latest: 2.3.1)
    - wry 🦀: 0.52.1
    - tao 🦀: 0.34.0
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli : 2.6.2 (outdated, latest: 2.7.0)

[-] Plugins
    - tauri-plugin-opener 🦀: 2.4.0
    - @tauri-apps/plugin-opener : not installed!

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../src
0 likes

No Answers yet.

Your answer might help someone💌