BlueStacks5 API
Description
A set of interfaces for managing the BlueStacks 5 emulator in ZennoDroid Enterprise.
| Interface | Description |
|---|---|
IBlueStacks5API | Starting, stopping, and connecting to the emulator |
IBlueStacks5SettingsAPI | System parameters: geolocation, IMEI |
IBlueStacks5RootAPI | Managing root access and Magisk |
IBlueStacks5ManagerAPI | Creating 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 inIP:Portformat (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:
trueif 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:
trueif the emulator is running; otherwisefalse.
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, andIsBootCompletedreturnstrue.Parameters:
timeout— how long to wait, in seconds (0checks once).
Returns:
trueif the emulator booted;falseif the time ran out.Description:
Call it after everyStart(): 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 (0checks once).
Returns:
trueif the connection answers;falseif the time ran out.Description:
Call it afterConnect(): 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 (0checks once).
Returns:
trueif the process is gone;falseif the time ran out.Description:
Call it after everyStop(): operations on a stopped instance,Unlock()andLock()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");
- After
Start(), wait for the boot withWaitForBoot()(or checkIsBootCompleted) before performing any actions. - After
Stop(), wait forWaitForStop(): the instance disks stay locked while the process is alive. Connect()should be called after the emulator has started, and the connection checked withWaitForConnect().- 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");
- 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:
trueif root answers; otherwisefalse.
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.zipfile (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.apkto take the binaries from.
Description:
The instance has to be stopped and unlocked withUnlock(patchImage: false). The Magisk manager app is installed separately, withInstallMagisk().
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.zipfile.
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.zipfile.
Returns:
trueif the module was written;falseif/datahas never been initialised.Description:
When the method returnsfalse, 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—trueis whatUnlock()does;falseskips 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 (0checks once).
Returns:
trueif root answers;falseif the time ran out.Description:
Call it afterWaitForBoot(): 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");
- 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, andRootShell(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:
trueif 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 asGetListNames().
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 takesMagiskSource.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.DefaultZygiskModuleis 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 asSetupRoot()— 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 takesMagiskSource.DefaultApk;zygiskModule— path to a Zygisk provider module.zip(NeoZygisk);MagiskSource.DefaultZygiskModuleis 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 2and 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 ofSetupRoot()andSetupRootOffline(). 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);
- Before creating/deleting instances, it is recommended to start the manager (
StartManager()). - The
cpusandramparameters must match the host machine's capabilities. - Incorrect graphics values may lead to unstable behavior.
- Used together with
IBlueStacks5APIfor the full cycle: create → start → automate → delete.