shizuku_api_plugin 1.0.3 copy "shizuku_api_plugin: ^1.0.3" to clipboard
shizuku_api_plugin: ^1.0.3 copied to clipboard

PlatformAndroid

Shizuku API is the API provided by Shizuku and Sui. With Shizuku API, you can call your Java/JNI code with root/shell (ADB) identity.

Shizuku API Flutter Plugin #

Shizuku API Flutter Plugin

A Flutter plugin to interact with the Shizuku API, allowing your application to execute shell commands with system or ADB privileges.

Pub Version API Reference Ask DeepWiki License CI GitHub stars

English | δΈ­ζ–‡

  • priv_kit β€” An app-owned privileged Android runtime.

Priv Kit supports startup through Root, ADB, Manual, and external authorization bridges.

πŸ“¦ Installation #

Add the dependency to your project:

flutter pub add shizuku_api_plugin

πŸ“‹ Requirements #

  • Flutter >=3.44.0 and Dart SDK ^3.12.0 are required.
  • The Shizuku app must be installed and running on the target device.

βš™οΈ Configuration #

πŸ”§ app/build.gradle #

Ensure that the minimum SDK version (minSdk) is set to 24 or higher.

πŸ“„ AndroidManifest.xml #

Add the Shizuku provider definition inside the <application> tag:


<application>
    <provider android:name="rikka.shizuku.ShizukuProvider"
        android:authorities="${applicationId}.shizuku" android:multiprocess="false"
        android:enabled="true" android:exported="true"
        android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />
</application>

πŸš€ Usage #

Each snippet below is a complete async function. In a real app, call it from your widget or service.

1. πŸ” Verify Shizuku Service #

Before executing any plugin commands, verify that the Shizuku service is running:

import 'package:shizuku_api_plugin/shizuku_api.dart';

Future<void> main() async {
  final shizukuApiPlugin = ShizukuApi();

  // Check if the Shizuku binder service is active
  final isBinderRunning = await shizukuApiPlugin.pingBinder() ?? false;
  print(isBinderRunning);
}

2. βœ… Check Permissions #

Check if Shizuku permissions have been granted to your application:

import 'package:shizuku_api_plugin/shizuku_api.dart';

Future<void> main() async {
  final shizukuApiPlugin = ShizukuApi();

  // Returns true if permission is granted, false if denied or not requested yet
  final hasPermission = await shizukuApiPlugin.checkPermission();
  print(hasPermission);
}

3. πŸ”‘ Request Permissions #

Request permissions from the user via the Shizuku system dialog:

import 'package:shizuku_api_plugin/shizuku_api.dart';

Future<void> main() async {
  final shizukuApiPlugin = ShizukuApi();

  // Triggers the Shizuku permission dialog
  // Returns true if permission is granted, false if declined
  final permissionGranted = await shizukuApiPlugin.requestPermission();
  print(permissionGranted);
}

4. ⌨️ Run Commands #

Execute ADB shell commands:

  • Note: Execution within a root environment (su) is untested.
  • Standard ADB shell commands are supported.
import 'package:shizuku_api_plugin/shizuku_api.dart';

Future<void> main() async {
  final shizukuApiPlugin = ShizukuApi();
  const command = 'pm uninstall --user 0 com.android.chrome';

  // Returns success if the command is executed and the system app is uninstalled
  final output = await shizukuApiPlugin.runCommand(command);
  print(output);
}

πŸ“– API Reference #

Methods exposed by ShizukuApi (all return a Future, so await is required):

Method Returns Description
pingBinder() Future<bool?> Whether the Shizuku binder service is active
checkPermission() Future<bool?> Whether Shizuku permission has been granted
requestPermission() Future<bool?> Shows the Shizuku permission dialog and returns the result
runCommand(String command) Future<String?> Executes a command as shell (ADB) and returns its output

Recommended order: pingBinder() β†’ checkPermission() β†’ requestPermission() (if not granted) β†’ runCommand().

πŸ’‘ Example #

A runnable example project is available in the example/ directory, demonstrating the full flow: check service β†’ check permission β†’ request permission β†’ run command.

❓ FAQ #

  • Command fails / no output: make sure the Shizuku app is started and running, and that your app has been granted permission.
  • No permission dialog: verify that pingBinder() returns true first; the dialog cannot be shown when Shizuku is not running.
  • Uncaught PlatformException: wrap the calls in try/catch and handle the failure gracefully.

For more questions, refer to the Shizuku documentation.

πŸ’› Support #

If shizuku_api_plugin helps you build better UIs, please consider supporting it.
It only takes a few seconds and helps other Flutter developers discover the library.

β˜•οΈ Buy Me a Coffee #

Buy Me a Coffee at ko-fi.com
1
likes
160
points
73
downloads
screenshot

Documentation

Documentation
API reference

Publisher

verified publishernoob-coder.com

Weekly Downloads

Shizuku API is the API provided by Shizuku and Sui. With Shizuku API, you can call your Java/JNI code with root/shell (ADB) identity.

Repository (GitHub)
View/report issues

Topics

#shizuku-api #adb #shell #root #system

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on shizuku_api_plugin

Packages that implement shizuku_api_plugin