tauri-apps/tauri · error

failed to write proguard-tauri.pro

Error message

failed to write proguard-tauri.pro

What it means

When TAURI_ANDROID_PROJECT_PATH is set, tauri's build script renders mobile/proguard-tauri.pro with the app's package name and writes it to <project>/app/proguard-tauri.pro. The expect fires when the write fails, typically because <project>/app does not exist or the directory is not writable.

Source

Thrown at crates/tauri/build.rs:333

        let out_path = kotlin_out_dir.join(file.file_name());
        // Overwrite only if changed to not trigger rebuilds
        write_if_changed(&out_path, &content).expect("Failed to write kotlin file");

        println!("cargo:rerun-if-changed={}", out_path.display());
      }
    }

    if let Some(project_dir) = env::var_os("TAURI_ANDROID_PROJECT_PATH").map(PathBuf::from) {
      let package_unescaped = env::var("TAURI_ANDROID_PACKAGE_UNESCAPED")
        .unwrap_or_else(|_| env_var("WRY_ANDROID_PACKAGE").replace('`', ""));
      let tauri_proguard =
        include_str!("./mobile/proguard-tauri.pro").replace("$PACKAGE", &package_unescaped);
      std::fs::write(
        project_dir.join("app").join("proguard-tauri.pro"),
        tauri_proguard,
      )
      .expect("failed to write proguard-tauri.pro");
    }

    let lib_path =
      PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("mobile/android");
    println!("cargo:android_library_path={}", lib_path.display());
  }

  #[cfg(target_os = "macos")]
  {
    if target_os == "ios" {
      let lib_path =
        PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("mobile/ios-api");
      tauri_utils::build::link_apple_library("Tauri", &lib_path);
      println!("cargo:ios_library_path={}", lib_path.display());
    }
  }

  let tauri_global_scripts = PathBuf::from("./scripts/bundle.global.js")

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Ensure <TAURI_ANDROID_PROJECT_PATH>/app exists; re-run tauri android init if unsure.
  2. Fix TAURI_ANDROID_PROJECT_PATH to the actual gen/android path.
  3. Make the Android project directory writable.
Defensive patterns

Strategy: validation

Validate before calling

if let Some(project) = std::env::var_os("TAURI_ANDROID_PROJECT_PATH") {
    let app_dir = std::path::PathBuf::from(project).join("app");
    assert!(app_dir.is_dir(), "{} is missing - run tauri android init", app_dir.display());
}

Prevention

When it happens

Trigger: TAURI_ANDROID_PROJECT_PATH pointing at a folder without an app/ subdirectory (deleted or never generated), or a read-only Android project directory.

Common situations: Android project folder pruned or only partly regenerated; env var pointing at the wrong directory; permission problems in CI.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/bb60cdc06d2c63cc. Report an issue: GitHub.