tauri-apps/tauri · error · tauri_cli::error::Error

Android folder already exists

Error message

Android folder already exists

What it means

`tauri plugin android init` refuses to overwrite existing output: before scaffolding the plugin's Android Kotlin sources it checks for an `android` directory inside the chosen output dir and bails if one exists, to protect manual changes you may have made.

Source

Thrown at crates/tauri-cli/src/plugin/android.rs:62

  /// The output directory.
  #[clap(short, long)]
  #[clap(default_value_t = current_dir().expect("failed to read cwd").to_string_lossy().into_owned())]
  out_dir: String,
}

pub fn command(cli: Cli) -> Result<()> {
  match cli.command {
    Commands::Init(options) => {
      let plugin_name = match options.plugin_name {
        None => super::infer_plugin_name(
          std::env::current_dir().context("failed to get current directory")?,
        )?,
        Some(name) => name,
      };

      let out_dir = PathBuf::from(options.out_dir);
      if out_dir.join("android").exists() {
        crate::error::bail!("Android folder already exists");
      }

      let plugin_id = prompts::input(
        "What should be the Android Package ID for your plugin?",
        Some(format!("com.plugin.{plugin_name}")),
        false,
        false,
      )?
      .unwrap();

      let handlebars = Handlebars::new();

      let mut data = BTreeMap::new();
      super::init::plugin_name_data(&mut data, &plugin_name);
      data.insert("android_package_id", handlebars::to_json(&plugin_id));

      let mut created_dirs = Vec::new();
      template::render_with_generator(

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. If you truly want a fresh scaffold, delete or move the existing `android/` folder first.
  2. Otherwise skip init — the plugin already has its Android sources.
  3. Use `--out-dir` to scaffold into a different location.
  4. Commit or back up manual changes inside android/ before deleting it.

Example fix

# before
tauri plugin android init
# error: Android folder already exists

# after
mv android android.bak   # or rm -rf android
tauri plugin android init
Defensive patterns

Strategy: validation

Validate before calling

test ! -e android \
  && tauri plugin android init \
  || echo "android/ already scaffolded - skipping init"

Prevention

When it happens

Trigger: Running `tauri plugin android init` (with default or explicit `--out-dir`) in a plugin crate that already contains an `android/` folder — i.e. init was already run once, or an unrelated folder named android exists there.

Common situations: Re-running init to 'refresh' a plugin template; CI automation that runs init on every build; picking an out-dir that already contains android sources from another plugin.

Related errors


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