{"record":{"id":"bb60cdc06d2c63cc","repo":"tauri-apps/tauri","slug":"failed-to-write-proguard-tauri-pro","errorCode":null,"errorMessage":"failed to write proguard-tauri.pro","messagePattern":"failed to write proguard-tauri\\.pro","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri/build.rs","lineNumber":327,"sourceCode":"\n        let out_path = kotlin_out_dir.join(file.file_name());\n        // Overwrite only if changed to not trigger rebuilds\n        write_if_changed(&out_path, &content).expect(\"Failed to write kotlin file\");\n\n        println!(\"cargo:rerun-if-changed={}\", out_path.display());\n      }\n    }\n\n    if let Some(project_dir) = env::var_os(\"TAURI_ANDROID_PROJECT_PATH\").map(PathBuf::from) {\n      let package_unescaped = env::var(\"TAURI_ANDROID_PACKAGE_UNESCAPED\")\n        .unwrap_or_else(|_| env_var(\"WRY_ANDROID_PACKAGE\").replace('`', \"\"));\n      let tauri_proguard =\n        include_str!(\"./mobile/proguard-tauri.pro\").replace(\"$PACKAGE\", &package_unescaped);\n      std::fs::write(\n        project_dir.join(\"app\").join(\"proguard-tauri.pro\"),\n        tauri_proguard,\n      )\n      .expect(\"failed to write proguard-tauri.pro\");\n    }\n\n    let lib_path =\n      PathBuf::from(std::env::var_os(\"CARGO_MANIFEST_DIR\").unwrap()).join(\"mobile/android\");\n    println!(\"cargo:android_library_path={}\", lib_path.display());\n  }\n\n  #[cfg(target_os = \"macos\")]\n  {\n    if target_os == \"ios\" {\n      let lib_path =\n        PathBuf::from(std::env::var_os(\"CARGO_MANIFEST_DIR\").unwrap()).join(\"mobile/ios-api\");\n      tauri_utils::build::link_apple_library(\"Tauri\", &lib_path);\n      println!(\"cargo:ios_library_path={}\", lib_path.display());\n    }\n  }\n\n  let tauri_global_scripts = PathBuf::from(\"./scripts/bundle.global.js\")","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri/build.rs#L309-L345","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify TAURI_ANDROID_PROJECT_PATH points at an existing Tauri Android project containing an app/ directory","Check write permissions on <project>/app and fix with chown/chmod","Regenerate the Android project (tauri android init) if the directory structure is broken","Free disk space / confirm the volume is writable"],"exampleFix":"// before\nexport TAURI_ANDROID_PROJECT_PATH=/stale/path/gen/android\n// after\nrm -rf /stale/path/gen/android\ntauri android init\nexport TAURI_ANDROID_PROJECT_PATH=$PWD/gen/android","handlingStrategy":"validation","validationCode":"let app_dir = std::path::Path::new(&project_dir).join(\"app\");\nassert!(app_dir.is_dir(), \"TAURI_ANDROID_PROJECT_PATH/app missing: {}\", app_dir.display());\nlet probe = app_dir.join(\".write-test\");\nstd::fs::write(&probe, b\"\").expect(\"app dir not writable\");\nlet _ = std::fs::remove_file(&probe);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run `tauri android init` before setting TAURI_ANDROID_PROJECT_PATH","Re-init the Android project after major Tauri upgrades","Close Android Studio during headless builds to avoid file locks"],"tags":["build-script","android","proguard","filesystem"],"backgroundTag":"file-write-failed","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}