Skip to content

smartclock-app/tauri-plugin-apk-intent

Repository files navigation

Tauri Plugin APK Intent

A Tauri v2 plugin that enables Android APK installation through the system install intent.

Features

  • ✅ Launch Android's system APK installer for any APK file
  • ✅ Android 7.0+ FileProvider support for secure file sharing
  • ✅ Automatic permission handling (REQUEST_INSTALL_PACKAGES on Android 8.0+)
  • ✅ Platform-specific: throws error on non-Android platforms (desktop/iOS)

Installation

1. Install the plugin

Add to your src-tauri/Cargo.toml:

[dependencies]
tauri-plugin-apk-intent = { git = "https://github.com/smartclock-app/tauri-plugin-apk-intent" }

2. Register the plugin

In your src-tauri/src/lib.rs:

fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_apk_intent::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

3. Grant permissions

In your src-tauri/capabilities/default.json:

{
  "permissions": ["apk-intent:default"]
}

Usage

JavaScript/TypeScript

async function installMyApp() {
  try {
    // Pass absolute file path to the APK
    await invoke("plugin:apk-intent|install_apk", {
      payload: {
        path: "/storage/emulated/0/Download/app.apk",
      },
    });
    console.log("Install intent launched!");
  } catch (error) {
    console.error("Installation failed:", error);
    // On desktop/iOS: "APK installation is only supported on Android"
  }
}

Requirements

Android

  • Minimum SDK: 21 (Android 5.0)
  • Target SDK: 26+ recommended (for proper permission handling)
  • Permission: REQUEST_INSTALL_PACKAGES (automatically added by plugin)

The plugin automatically:

  • Uses FileProvider for Android 7.0+ (secure file URIs)
  • Falls back to file:// URIs for Android 6.0 and below
  • Handles permission prompts on Android 8.0+ (user will see system dialog)

Other Platforms

Desktop (Windows, macOS, Linux) and iOS will throw an error:

Error: APK installation is only supported on Android

How It Works

  1. Validates the APK file exists and has .apk extension
  2. Converts file path to appropriate URI (FileProvider or file://)
  3. Launches system install intent with ACTION_INSTALL_PACKAGE
  4. Returns immediately (does not wait for user to complete installation)

License

Apache-2.0

Notes

  • The plugin only launches the installer UI - it doesn't programmatically install the APK
  • Users must manually confirm the installation in the system dialog
  • On Android 8.0+, users must grant "Install unknown apps" permission if not already granted
  • Silent installation requires system/privileged app status (not supported by this plugin)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors