tauri-apps/tauri · error

failed to write proguard-tauri.pro

Error message

failed to write proguard-tauri.pro

What it means

Build-script panic when std::fs::write cannot write the generated proguard-tauri.pro file into the Android project's app directory. This file carries Tauri's required ProGuard/R8 keep rules and is written whenever TAURI_ANDROID_PROJECT_PATH is set. Failure aborts the crate build.

Solutions

  1. Verify TAURI_ANDROID_PROJECT_PATH points at an existing Tauri Android project containing an app/ directory
  2. Check write permissions on <project>/app and fix with chown/chmod
  3. Regenerate the Android project (tauri android init) if the directory structure is broken
  4. Free disk space / confirm the volume is writable

Example fix

// before
export TAURI_ANDROID_PROJECT_PATH=/stale/path/gen/android
// after
rm -rf /stale/path/gen/android
tauri android init
export TAURI_ANDROID_PROJECT_PATH=$PWD/gen/android
Defensive patterns

Strategy: validation

Validate before calling

let app_dir = std::path::Path::new(&project_dir).join("app");
assert!(app_dir.is_dir(), "TAURI_ANDROID_PROJECT_PATH/app missing: {}", app_dir.display());
let probe = app_dir.join(".write-test");
std::fs::write(&probe, b"").expect("app dir not writable");
let _ = std::fs::remove_file(&probe);

Prevention

When it happens

Trigger: Running an Android build with TAURI_ANDROID_PROJECT_PATH set while <project>/app is missing, unwritable, or the path points somewhere that cannot hold the file (permissions, read-only FS, disk full).

Common situations: TAURI_ANDROID_PROJECT_PATH pointing at a stale, moved, or incorrectly initialized Tauri Android project; IDE (Android Studio) holding locks on files in the project; building with a user that lacks write access to the generated Android project.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18). Data as JSON: /api/errors/bb60cdc06d2c63cc. Report an issue: GitHub.

Appendix: source

Thrown at crates/tauri/build.rs:327

        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 460ec35447)