tauri-apps/tauri · error

Failed to install Android SDK

Error message

Failed to install Android SDK

What it means

The CLI successfully launched sdkmanager to install platform-tools, platforms;android-{SDK_VERSION} and ndk;{NDK_VERSION}, but the command exited with a non-zero status. The underlying sdkmanager output is printed above the error; typical causes are unaccepted licenses, network/proxy failures, disk space, or an incompatible/missing Java runtime.

Source

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

          crate::error::bail!("Skipping Android Studio SDK installation. Please go through the manual setup process described in the documentation: https://tauri.app/start/prerequisites/#android");
        }
      }

      log::info!("Running sdkmanager to install platform-tools, android-{SDK_VERSION} and ndk-{NDK_VERSION} on {}...", default_android_home.display());
      let status = Command::new(&sdk_manager_path)
        .arg(format!("--sdk_root={}", default_android_home.display()))
        .arg("--install")
        .arg("platform-tools")
        .arg(format!("platforms;android-{SDK_VERSION}"))
        .arg(format!("ndk;{NDK_VERSION}"))
        .status()
        .map_err(|error| Error::CommandFailed {
          command: format!("{} --sdk_root={} --install platform-tools platforms;android-{SDK_VERSION} ndk;{NDK_VERSION}", sdk_manager_path.display(), default_android_home.display()),
          error,
        })?;

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

    std::env::set_var("ANDROID_HOME", default_android_home);
  }

  Ok(())
}

fn ensure_ndk(non_interactive: bool) -> Result<()> {
  // re-evaluate ANDROID_HOME
  let android_home = std::env::var_os("ANDROID_HOME")
    .or_else(|| std::env::var_os("ANDROID_SDK_ROOT"))
    .map(PathBuf::from)
    .context("Failed to locate Android SDK")?;

  // check NDK_HOME
  let mut installed_ndks = if let Some(ndk_home) = std::env::var_os("NDK_HOME") {

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Run the sdkmanager command printed in the error manually to see the full failure output
  2. Accept licenses: `yes | sdkmanager --licenses` then rerun the tauri command
  3. Fix network/proxy or Java issues (install JDK 17+, ensure JAVA_HOME is valid), free disk space, then retry
  4. On CI, cache the SDK directory so the install step is skipped after the first run

Example fix

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

Strategy: retry

Validate before calling

# pre-accept licenses so sdkmanager cannot fail on them:
yes | sdkmanager --licenses >/dev/null 2>&1
df -h "$ANDROID_HOME" | tail -1   # NDK/platform need ~2GB+ free

Try / catch

#!/usr/bin/env bash
for i in 1 2 3; do
  tauri android build --ci && exit 0
  echo "retry $i: sdkmanager install failed - check licenses/network"
done
exit 1

Prevention

When it happens

Trigger: `sdkmanager --sdk_root=... --install platform-tools platforms;android-X ndk;Y` returning non-zero — e.g. licenses not accepted, HTTP 403/timeout behind a proxy, 'Could not determine java version', or insufficient disk space.

Common situations: Fresh CI machines that never ran `sdkmanager --licenses`; corporate proxies blocking dl.google.com; JAVA_HOME pointing to an unsupported JDK; full disk in Docker builds.

Related errors


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