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

Failed to install Android NDK

Error message

Failed to install Android NDK

What it means

sdkmanager was launched to install ndk;{NDK_VERSION} but exited non-zero. The command line is included in the error context; the sdkmanager output above it usually reveals the real cause (unaccepted license, download failure, disk space, or a broken Java installation).

Source

Thrown at crates/tauri-cli/src/mobile/android/mod.rs:678

      "Running sdkmanager to install ndk-{NDK_VERSION} on {}...",
      android_home.display()
    );
    let status = Command::new(&sdk_manager_path)
      .arg(format!("--sdk_root={}", android_home.display()))
      .arg("--install")
      .arg(format!("ndk;{NDK_VERSION}"))
      .status()
      .map_err(|error| Error::CommandFailed {
        command: format!(
          "{} --sdk_root={} --install ndk;{NDK_VERSION}",
          sdk_manager_path.display(),
          android_home.display()
        ),
        error,
      })?;

    if !status.success() {
      crate::error::bail!("Failed to install Android NDK");
    }

    let ndk_path = android_home.join("ndk").join(NDK_VERSION);
    log::info!("Installed NDK: {}", ndk_path.display());
    std::env::set_var("NDK_HOME", ndk_path);
  }

  Ok(())
}

fn delete_codegen_vars() {
  for (k, _) in std::env::vars() {
    if k.starts_with("WRY_") && (k.ends_with("CLASS_EXTENSION") || k.ends_with("CLASS_INIT")) {
      std::env::remove_var(k);
    }
  }
}

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Run the exact sdkmanager command from the error output manually and read the failure reason
  2. Accept licenses: `yes | sdkmanager --licenses`, then retry the tauri command
  3. Free disk space (NDK needs ~2GB+) and check network/proxy, then retry
  4. Pin/cache the NDK in CI so the install step succeeds once and is reused

Example fix

# before
error: Failed to install Android NDK
# after
yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --licenses
$ANDROID_HOME/cmdline-tools/bin/sdkmanager --install "ndk;27.0.0"
tauri android dev
Defensive patterns

Strategy: retry

Validate before calling

yes | sdkmanager --licenses >/dev/null 2>&1
df -h "$ANDROID_HOME" | tail -1   # NDK archive is ~1-2GB

Try / catch

#!/usr/bin/env bash
for i in 1 2 3; do
  tauri android dev && exit 0
echo "retry $i: NDK install failed (licenses/network/disk?)"
done
exit 1

Prevention

When it happens

Trigger: `sdkmanager --sdk_root=... --install ndk;X` failing — most often 'License not accepted' for the NDK package, network errors downloading the ~1GB archive, or java.io errors.

Common situations: CI never accepting NDK licenses; flaky networks/proxies during the large NDK download; Docker layers running out of disk; ANDROID_HOME on a filesystem that ran out of inodes/space.

Related errors


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