Skip to main content

BlueStacks5 API

Description​

A set of interfaces for managing the BlueStacks 5 emulator in ZennoDroid Enterprise.

InterfaceDescription
IBlueStacks5APIStarting, stopping, and connecting to the emulator
IBlueStacks5SettingsAPISystem parameters: geolocation, IMEI
IBlueStacks5RootAPIManaging root access and Magisk
IBlueStacks5ManagerAPICreating and deleting instances via the manager

IBlueStacks5API​

Managing the startup, shutdown, and connection of the BlueStacks 5 emulator.

AddressPort​

  • string AddressPort { get; }
    Connection address and port of the emulator.

    Returns:
    A string in IP:Port format (e.g. 127.0.0.1:5555).

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");

string addressPort = bs.AddressPort; // 127.0.0.1:5555

IsBootCompleted​

  • bool IsBootCompleted { get; }
    Checks whether Android has finished booting inside the emulator.

    Returns:
    true if the system is fully loaded and ready to use.

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");

if (!bs.IsBootCompleted)
throw new Exception("Android has not booted yet");

IsRunning​

  • bool IsRunning { get; }
    Checks whether the emulator is running.

    Returns:
    true if the emulator is running; otherwise false.

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");

if (!bs.IsRunning) bs.Start();

Connect​

  • void Connect()
    Connects to the emulator (typically via ADB).

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");
bs.Connect();

Disconnect​

  • void Disconnect()
    Disconnects from the emulator.

Example​

new BlueStacks5("Rvc64_1", "nxt").Disconnect();

Start​

  • void Start()
    Starts the BlueStacks emulator.

Example​

new BlueStacks5("Rvc64_1", "nxt").Start();

Stop​

  • void Stop()
    Stops the emulator.

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");
bs.Stop();
bs.WaitForStop(60);

WaitForBoot​

  • bool WaitForBoot(int timeout)
    Waits until Android has finished booting: the process is running, ADB is connected, and IsBootCompleted returns true.

    Parameters:

    • timeout — how long to wait, in seconds (0 checks once).

    Returns:
    true if the emulator booted; false if the time ran out.

    Description:
    Call it after every Start(): that one returns immediately, without waiting for the boot.

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");
bs.Start();
if (!bs.WaitForBoot(120)) throw new Exception("The emulator did not boot");

WaitForConnect​

  • bool WaitForConnect(int timeout)
    Connects over ADB and waits until the connection actually answers a command.

    Parameters:

    • timeout — how long to keep trying, in seconds (0 checks once).

    Returns:
    true if the connection answers; false if the time ran out.

    Description:
    Call it after Connect(): the emulator does not start answering commands right away.

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");
bs.Connect();
if (!bs.WaitForConnect(60)) throw new Exception("The ADB connection does not answer");

WaitForStop​

  • bool WaitForStop(int timeout)
    Waits until the emulator process is gone.

    Parameters:

    • timeout — how long to wait, in seconds (0 checks once).

    Returns:
    true if the process is gone; false if the time ran out.

    Description:
    Call it after every Stop(): operations on a stopped instance, Unlock() and Lock() among them, need the process to be gone.

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");
bs.Stop();
if (!bs.WaitForStop(60)) throw new Exception("The emulator did not shut down");
Important Notes
  • After Start(), wait for the boot with WaitForBoot() (or check IsBootCompleted) before performing any actions.
  • After Stop(), wait for WaitForStop(): the instance disks stay locked while the process is alive.
  • Connect() should be called after the emulator has started, and the connection checked with WaitForConnect().
  • In some scenarios, reconnection may be required when ADB fails.

IBlueStacks5SettingsAPI​

Modifying system parameters of the BlueStacks 5 emulator.

SetGeo​

  • void SetGeo(double longitude, double latitude)
    Sets the device's geolocation.

    Parameters:

    • longitude — longitude (e.g. 37.6173);
    • latitude — latitude (e.g. 55.7558).

    Description:
    Allows emulating the device's location at a specified point on the map.

Example​

new BlueStacks5Settings("Rvc64_1", "nxt").SetGeo(-73.572604, 40.651980);

SetIMEI​

  • void SetIMEI(string value)
    Sets the device IMEI.

    Parameters:

    • value — IMEI string value.

    Description:
    Used to spoof the device identifier.

Example​

new BlueStacks5Settings("Rvc64_1", "nxt").SetIMEI("356938035643809");
Important Notes
  • Invalid IMEI values may cause errors in applications or be detected as invalid.
  • After changing parameters, it is recommended to restart the emulator and reconnect.
  • Geolocation may additionally be cached by applications — sometimes a restart is required.

IBlueStacks5RootAPI​

Managing root access, Magisk, and patches in the BlueStacks 5 emulator.

IsRooted​

  • bool IsRooted { get; }
    Checks whether root answers on the instance right now.

    Returns:
    true if root answers; otherwise false.

Example​

var root = new BlueStacks5Root("Rvc64_1", "nxt");

bool rooted = root.IsRooted;

EnableZygisk​

  • void EnableZygisk()
    Enables Zygisk — a Magisk module for injecting into processes via Zygote. Supported on Android 9 (Pie) and above.

    Description:
    Allows using advanced modules and hooks (e.g. for bypassing root detection).

Example​

new BlueStacks5Root("Rvc64_1", "nxt").EnableZygisk();

  • void EnableZygisk(string modulePath)
    Enables Zygisk using the given provider module — for the Magisk builds whose own Zygisk cannot be used on an emulator. The module is installed first, then Zygisk is configured to defer to it.

    Parameters:

    • modulePath — path to the Zygisk provider module .zip file (NeoZygisk).

    Description:
    Takes effect after the emulator is restarted. Not supported on Android 7.

Example​

var root = new BlueStacks5Root("Rvc64_1", "nxt");
root.EnableZygisk(MagiskSource.DefaultZygiskModule);

FlashMagisk​

  • void FlashMagisk()
    Flashes (installs) Magisk into the system.

    Description:
    Applies Magisk at the system level after installation.

Example​

new BlueStacks5Root("Rvc64_1", "nxt").FlashMagisk();

InstallMagisk​

  • void InstallMagisk(string path)
    Installs Magisk from the specified file.

    Parameters:

    • path — path to the Magisk file (.apk).

Example​

new BlueStacks5Root("Rvc64_1", "nxt").InstallMagisk(MagiskSource.DefaultApk);

InstallMagiskOffline​

  • void InstallMagiskOffline(string magiskApk)
    Lays Magisk out on the system image of a stopped, unlocked instance, without starting anything.

    Parameters:

    • magiskApk — path to the Magisk .apk to take the binaries from.

    Description:
    The instance has to be stopped and unlocked with Unlock(patchImage: false). The Magisk manager app is installed separately, with InstallMagisk().

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");
var root = new BlueStacks5Root("Rvc64_1", "nxt");

bs.Stop();
bs.WaitForStop(60);
root.Unlock(patchImage: false);
root.InstallMagiskOffline(MagiskSource.DefaultApk);
bs.Start();
bs.WaitForBoot(120);
root.WaitForRoot(60);

InstallModule​

  • void InstallModule(string path)
    Installs a Magisk module from the specified zip file (LSPosed, Vector, and others).

    Parameters:

    • path — path to the module .zip file.

    Description:
    Modules are applied when the emulator is restarted.

Example​

new BlueStacks5Root("Rvc64_1", "nxt").InstallModule(@"C:\Modules\LSPosed.zip");

InstallModuleOffline​

  • bool InstallModuleOffline(string modulePath)
    Puts a Zygisk provider module into the data image of a stopped instance, laid out the way the installer of the module would have laid it out.

    Parameters:

    • modulePath — path to the Zygisk provider module .zip file.

    Returns:
    true if the module was written; false if /data has never been initialised.

    Description:
    When the method returns false, boot the instance once and call it again. Not supported on Android 7.

Example​

var root = new BlueStacks5Root("Rvc64_1", "nxt");

if (!root.InstallModuleOffline(MagiskSource.DefaultZygiskModule))
{
// /data has not been laid out yet - boot once and call it again
}

Lock​

  • void Lock()
    Locks root access in the emulator. Restores the system partition to a non-root state.

    Description:
    Disables root, making the system more "clean" (e.g. for bypassing application checks).

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");
bs.Stop();
bs.WaitForStop(60);

new BlueStacks5Root("Rvc64_1", "nxt").Lock();

Patch​

  • void Patch()
    Applies a patch to prepare the system for root.

    Description:
    Modifies emulator system components to support root access.

Example​

new BlueStacks5Root("Rvc64_1", "nxt").Patch();

Unlock​

  • void Unlock()
    Unlocks root access.

    Description:
    Puts the system partition in write mode. Allows making changes to gain root access.

Example​

new BlueStacks5Root("Rvc64_1", "nxt").Unlock();

  • void Unlock(bool patchImage)
    The same unlock, with a say over whether the system image is also patched.

    Parameters:

    • patchImage — true is what Unlock() does; false skips the patch.

Example​

new BlueStacks5Root("Rvc64_1", "nxt").Unlock(patchImage: false);

WaitForRoot​

  • bool WaitForRoot(int timeout)
    Waits until root answers.

    Parameters:

    • timeout — how long to wait, in seconds (0 checks once).

    Returns:
    true if root answers; false if the time ran out.

    Description:
    Call it after WaitForBoot(): root does not start answering the moment Android is up.

Example​

var bs = new BlueStacks5("Rvc64_1", "nxt");
var root = new BlueStacks5Root("Rvc64_1", "nxt");

bs.Start();
bs.WaitForBoot(120);
if (!root.WaitForRoot(60)) throw new Exception("Root did not come up");
Important Notes
  • Root operations may affect emulator stability or break application functionality.
  • After changes, restarting the emulator and verifying root status is recommended.
  • Used together with IFridaDeviceAPI, IDroidAppAPI, and RootShell (IDroidInputAPI).

IBlueStacks5ManagerAPI​

Managing BlueStacks 5 instances via the manager: creating, deleting, starting/stopping the service.

Constructor: BlueStacks5Manager(string oem)

  • oem — string identifying the BlueStacks version:
    • "nxt" — standard version
    • "nxt_cn" — China version
    • "msi5" — MSI version (MSI App Player 5)

Create​

  • string Create(string imageName, int cpus, int ram, string graphicEngine, string graphicRenderer, string deviceProfile, string abiList)
    Creates a new emulator instance with the specified parameters.

    Parameters:

    • imageName — base emulator image:
      • "Nougat32" — Android 7.1 (x86)
      • "Nougat64" — Android 7.1 (x64)
      • "Pie64" — Android 9.0 (x64)
      • "Rvc64" — Android 11.0 (x64)
      • "Tiramisu64" — Android 13.0 (x64)
    • cpus — number of allocated CPUs;
    • ram — amount of RAM (MB);
    • graphicEngine — graphics engine (Android 7 only):
      • "aga" — Compatibility
      • "pga" — Performance
    • graphicRenderer — render type:
      • "gl" — OpenGL
      • "dx" — DirectX
      • "vlcn" — Vulkan
    • deviceProfile — device profile:
      • "rogt" — Asus ROG 2
      • "ptxg" — Google Pixel 2XL
      • "optp" — OnePlus 10 Pro
      • "opet" — OnePlus 8T
      • "anfg" — Samsung Galaxy A90 5G
      • "smtn" — Samsung Galaxy S10
      • "stfg" — Samsung Galaxy S10 5G
      • "stul" — Samsung Galaxy S20 Ultra
      • "stwp" — Samsung Galaxy S20+
      • "stou" — Samsung Galaxy S21 Ultra
      • "sstt" — Samsung Galaxy S22
      • "sttu" — Samsung Galaxy S22 Ultra
      • "xitp" — Xiaomi 11T Pro
    • abiList — list of supported ABIs (e.g. "x86,x64,arm,arm64").

    Returns:
    The name of the created instance.

Example​

var name = new BlueStacks5Manager("nxt").Create("Rvc64",
cpus:2,
ram:2048,
graphicEngine:"aga",
graphicRenderer:"dx",
deviceProfile:"xitp",
abiList:"x86,x64,arm,arm64");

DeleteByName​

  • void DeleteByName(string name)
    Deletes an emulator instance by name.

    Parameters:

    • name — instance name.

Example​

new BlueStacks5Manager("nxt").DeleteByName("Rvc64_1");

Exists​

  • bool Exists(string name)
    Checks whether an instance with the given system name exists.

    Parameters:

    • name — system name of the instance.

    Returns:
    true if such an instance is registered.

    Description:
    Addressing one that does not exist — new BlueStacks5(name) and the like — is an error, so this is the way to ask first.

Example​

var mgr = new BlueStacks5Manager("nxt");

if (!mgr.Exists("Rvc64_1")) throw new Exception("The instance was not found");

GetListNames​

  • string[] GetListNames()
    System names of everything this OEM has registered.

    Returns:
    An array of system names.

    Description:
    Base images are among them — those are what new instances are cloned from, and they are listed exactly as an instance would be.

Example​

var mgr = new BlueStacks5Manager("nxt");

foreach (var name in mgr.GetListNames())
project.SendInfoToLog(name); // Rvc64, Rvc64_1, Pie64, ...

GetListTitles​

  • string[] GetListTitles()
    Display titles of the same list.

    Returns:
    An array of titles, in the same order as GetListNames().

Example​

var mgr = new BlueStacks5Manager("nxt");

var names = mgr.GetListNames();
var titles = mgr.GetListTitles();

for (int i = 0; i < names.Length; i++)
project.SendInfoToLog($"{titles[i]} -> {names[i]}"); // BlueStacks App Player 1 -> Rvc64_1

NameToTitleConverter​

  • string NameToTitleConverter(string name)
    Converts an internal system name back to the display title shown in the interface.

    Parameters:

    • name — system name of the instance.

    Returns:
    Display title of the instance.

Example​

string title = new BlueStacks5Manager("nxt").NameToTitleConverter("Rvc64_1"); // BlueStacks App Player 1

SetupRoot​

  • void SetupRoot(string title, string magiskApk, string zygiskModule, int timeout)
    Runs the whole root pipeline on the instance and leaves it running, rooted, with Zygisk live.

    Parameters:

    • title — display title as shown in the BlueStacks interface (a system name is accepted too);
    • magiskApk — path to the Magisk .apk. Empty takes MagiskSource.DefaultApk, the copy that ships with ZennoDroid;
    • zygiskModule — path to a Zygisk provider module .zip (NeoZygisk), which is what the Magisk builds whose own Zygisk cannot work on an emulator need; MagiskSource.DefaultZygiskModule is the copy that ships with ZennoDroid. Empty turns on Magisk's own Zygisk instead;
    • timeout — how long each wait in the sequence may take, in seconds.

Example​

var mgr = new BlueStacks5Manager("nxt");
mgr.SetupRoot("BlueStacks App Player 1", "", "", 120);

SetupRootOffline​

  • void SetupRootOffline(string title, string magiskApk, string zygiskModule, int timeout)
    The same result as SetupRoot() — a running, rooted instance with Zygisk live — reached by writing Magisk into the disk images instead of installing it into a running Android.

    Parameters:

    • title — display title as shown in the BlueStacks interface (a system name is accepted too);
    • magiskApk — the Magisk .apk: both the source of the binaries written into the image and the manager installed afterwards. Empty takes MagiskSource.DefaultApk;
    • zygiskModule — path to a Zygisk provider module .zip (NeoZygisk); MagiskSource.DefaultZygiskModule is the copy that ships with ZennoDroid. Empty installs Magisk alone, without Zygisk;
    • timeout — how long each stop, boot and root wait may take, in seconds.

Example​

var mgr = new BlueStacks5Manager("nxt");
mgr.SetupRootOffline("BlueStacks App Player 1", "", "", 120);

StartManager​

  • void StartManager()
    Starts the BlueStacks manager (instance management service).

Example​

new BlueStacks5Manager("nxt").StartManager();

StopManager​

  • void StopManager()
    Stops the BlueStacks manager.

Example​

new BlueStacks5Manager("nxt").StopManager();

TitleToNameConverter​

  • string TitleToNameConverter(string title)
    Converts an emulator display name to its system name.

    Parameters:

    • title — display name as shown in the BlueStacks interface: BlueStacks App Player 1, BlueStacks App Player 2 and so on.

    Returns:
    Internal instance name used by the system.

Example​

string name = new BlueStacks5Manager("nxt").TitleToNameConverter("BlueStacks App Player 1");

Unroot​

  • void Unroot(string title, int timeout)
    Takes root back off the instance — the counterpart of SetupRoot() and SetupRootOffline(). The instance is stopped and left stopped.

    Parameters:

    • title — display title as shown in the BlueStacks interface (a system name is accepted too);
    • timeout — how long the stop may take, in seconds.

Example​

new BlueStacks5Manager("nxt").Unroot("BlueStacks App Player 1", 120);
Important Notes
  • Before creating/deleting instances, it is recommended to start the manager (StartManager()).
  • The cpus and ram parameters must match the host machine's capabilities.
  • Incorrect graphics values may lead to unstable behavior.
  • Used together with IBlueStacks5API for the full cycle: create → start → automate → delete.