![]() |
VOOZH | about |
dotnet add package AdvancedSharpAdbClient --version 3.6.16
NuGet\Install-Package AdvancedSharpAdbClient -Version 3.6.16
<PackageReference Include="AdvancedSharpAdbClient" Version="3.6.16" />
<PackageVersion Include="AdvancedSharpAdbClient" Version="3.6.16" />Directory.Packages.props
<PackageReference Include="AdvancedSharpAdbClient" />Project file
paket add AdvancedSharpAdbClient --version 3.6.16
#r "nuget: AdvancedSharpAdbClient, 3.6.16"
#:package AdvancedSharpAdbClient@3.6.16
#addin nuget:?package=AdvancedSharpAdbClient&version=3.6.16Install as a Cake Addin
#tool nuget:?package=AdvancedSharpAdbClient&version=3.6.16Install as a Cake Tool
| Issues | License | NuGet |
|---|---|---|
| 👁 Github Issues |
👁 License |
👁 NuGet Status |
AdvancedSharpAdbClient is a .NET library that allows .NET applications to communicate with Android devices.
It provides a .NET implementation of the adb protocol, giving more flexibility to the developer than launching an
adb.exe process and parsing the console output.
It's upgraded version of SharpAdbClient. Added important features.
To install AdvancedSharpAdbClient install the AdvancedSharpAdbClient NuGetPackage. If you're using Visual Studio, you can run the following command in the Package Manager Console:
PM> Install-Package AdvancedSharpAdbClient
AdvancedSharpAdbClient does not communicate directly with your Android devices, but uses the adb.exe server process as an intermediate. Before you can connect to your Android device, you must first start the adb.exe server.
You can do so by either running adb.exe yourself (it comes as a part of the ADK, the Android Development Kit), or you can use the AdbServer.StartServer method like this:
if (!AdbServer.Instance.GetStatus().IsRunning)
{
AdbServer server = new AdbServer();
StartServerResult result = server.StartServer(@"C:\adb\adb.exe", false);
if (result != StartServerResult.Started)
{
Console.WriteLine("Can't start adb server");
}
}
Before using all the methods, you must initialize the new AdbClient class and then connect to the device
If you want to automate 2 or more devices at the same time, you must remember: 1 device - 1 AdbClient class
You can look at the examples to understand more
static AdbClient adbClient;
static DeviceData deviceData;
static void Main(string[] args)
{
adbClient = new AdbClient();
adbClient.Connect("127.0.0.1:62001");
device = adbClient.GetDevices().FirstOrDefault(); // Get first connected device
...
}
You can find the element on the screen by xpath
static DeviceClient deviceClient;
static void Main(string[] args)
{
...
deviceClient = new DeviceClient(adbClient, deviceData);
Element element = deviceClient.FindElement("//node[@text='Login']");
...
}
You can also specify the waiting time for the element
Element element = deviceClient.FindElement("//node[@text='Login']", TimeSpan.FromSeconds(5));
And you can find several elements
Element[] element = deviceClient.FindElements("//node[@resource-id='Login']", TimeSpan.FromSeconds(5));
You can get all element attributes
static void Main(string[] args)
{
...
Element element = deviceClient.FindElement("//node[@resource-id='Login']", TimeSpan.FromSeconds(3));
string eltext = element.Attributes["text"];
string bounds = element.Attributes["bounds"];
...
}
You can click on the x and y coordinates
static void Main(string[] args)
{
...
deviceClient.Click(600, 600); // Click on the coordinates (600;600)
...
}
Or on the element(need xpath)
static void Main(string[] args)
{
...
Element element = deviceClient.FindElement("//node[@text='Login']", TimeSpan.FromSeconds(3));
element.Click(); // Click on element by xpath //node[@text='Login']
...
}
The Click() method throw ElementNotFoundException if the element is not found
try
{
element.Click();
}
catch (Exception ex)
{
Console.WriteLine($"Can't click on the element:{ex.Message}");
}
You can swipe from one element to another
static void Main(string[] args)
{
...
Element first = deviceClient.FindElement("//node[@text='Login']");
Element second = deviceClient.FindElement("//node[@text='Password']");
deviceClient.Swipe(first, second, 100); // Swipe 100 ms
...
}
Or swipe by coordinates
static void Main(string[] args)
{
...
deviceClient.Swipe(600, 1000, 600, 500, 100); // Swipe from (600;1000) to (600;500) on 100 ms
...
}
The Swipe() method throw ElementNotFoundException if the element is not found
try
{
deviceClient.Swipe(0x2232323, 0x954, 0x9128, 0x11111, 200);
...
deviceClient.Swipe(first, second, 200);
}
catch (Exception ex)
{
Console.WriteLine($"Can't swipe:{ex.Message}");
}
You can send any text except Cyrillic (Russian isn't supported by adb)
The text field should be in focus
static void Main(string[] args)
{
...
deviceClient.SendText("text"); // Send text to device
...
}
You can also send text to the element (clicks on the element and sends the text)
static void Main(string[] args)
{
...
deviceClient.FindElement("//node[@resource-id='Login']").SendText("text"); // Send text to the element by xpath //node[@resource-id='Login']
...
}
The SendText() method throw InvalidTextException if text is incorrect
try
{
deviceClient.SendText(null);
}
catch (Exception ex)
{
Console.WriteLine($"Can't send text:{ex.Message}");
}
You can clear text input
The text field should be in focus
Recommended
static void Main(string[] args)
{
...
deviceClient.ClearInput(25); // The argument is to specify the maximum number of characters to be erased
...
}
It may work unstable
static void Main(string[] args)
{
...
deviceClient.FindElement("//node[@resource-id='Login']").ClearInput(); // Get element text attribute and remove text length symbols
...
}
You can see key events here https://developer.android.com/reference/android/view/KeyEvent#constants
static void Main(string[] args)
{
...
deviceClient.SendKeyEvent("KEYCODE_TAB");
...
}
The SendKeyEvent method throw InvalidKeyEventException if key event is incorrect
try
{
deviceClient.SendKeyEvent(null);
}
catch (Exception ex)
{
Console.WriteLine($"Can't send keyevent:{ex.Message}");
}
static void Main(string[] args)
{
...
deviceClient.ClickBackButton(); // Click Back button
...
deviceClient.ClickHomeButton(); // Click Home button
...
}
Some commands require Root
static void Main(string[] args)
{
...
PackageManager manager = new PackageManager(adbClient, deviceData);
manager.InstallPackage(@"C:\Users\me\Documents\mypackage.apk");
manager.UninstallPackage("com.android.app");
...
}
Or you can use AdbClient.Install
static void Main(string[] args)
{
...
using (FileStream stream = File.OpenRead("Application.apk"))
{
adbClient.Install(device, stream);
adbClient.Uninstall(device, "com.android.app");
}
...
}
static void Main(string[] args)
{
...
PackageManager manager = new PackageManager(adbClient, deviceData);
manager.InstallMultiplePackage(@"C:\Users\me\Documents\base.apk", new[] { @"C:\Users\me\Documents\split_1.apk", @"C:\Users\me\Documents\split_2.apk" }); // Install split app whith base app
manager.InstallMultiplePackage(new[] { @"C:\Users\me\Documents\split_3.apk", @"C:\Users\me\Documents\split_4.apk" }, "com.android.app"); // Add split app to base app which packagename is 'com.android.app'
...
}
Or you can use AdbClient.InstallMultiple
static void Main(string[] args)
{
...
adbClient.InstallMultiple(device, File.OpenRead("base.apk"), new[] { File.OpenRead("split_1.apk"), File.OpenRead("split_2.apk") }); // Install split app whith base app
adbClient.InstallMultiple(device, new[] { File.OpenRead("split_3.apk"), File.OpenRead("split_4.apk") }, "com.android.app"); // Add split app to base app which packagename is 'com.android.app'
...
}
static void Main(string[] args)
{
...
deviceClient.StartApp("com.android.app");
deviceClient.StopApp("com.android.app"); // force-stop
...
}
static async void Main(string[] args)
{
...
Image img = adbClient.GetFrameBuffer(deviceData, CancellationToken.None); // synchronously
...
Image img = await adbClient.GetFrameBufferAsync(deviceData, CancellationToken.None); // asynchronously
...
}
static void Main(string[] args)
{
...
XmlDocument screen = deviceClient.DumpScreen();
...
}
void DownloadFile()
{
using (SyncService service = new SyncService(deviceData))
{
using (FileStream stream = File.OpenWrite(@"C:\MyFile.txt"))
{
service.Pull("/data/local/tmp/MyFile.txt", stream, null);
}
}
}
void UploadFile()
{
using (SyncService service = new SyncService(deviceData))
{
using (FileStream stream = File.OpenRead(@"C:\MyFile.txt"))
{
service.Push(stream, "/data/local/tmp/MyFile.txt", UnixFileStatus.DefaultFileMode, DateTimeOffset.Now, null);
}
}
}
static async void Main(string[] args)
{
...
ConsoleOutputReceiver receiver = new ConsoleOutputReceiver();
adbClient.ExecuteRemoteCommand("echo Hello, World", device, receiver); // synchronously
...
await adbClient.ExecuteRemoteCommandAsync("echo Hello, World", device, receiver, default); // asynchronously
...
}
Default encoding is UTF8, if you want to change it, use
AdbClient.SetEncoding(Encoding.ASCII);
Please open an issue on if you have suggestions or problems.
AdvancedSharpAdbClient is a fork of SharpAdbClient and madb which in itself is a .NET port of the ddmlib Java Library.
Credits: https://github.com/camalot, https://github.com/quamotion
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net8.0-windows10.0.17763 net8.0-windows10.0.17763 is compatible. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. net10.0-windows10.0.17763 net10.0-windows10.0.17763 is compatible. |
| .NET Core | netcoreapp1.0 netcoreapp1.0 was computed. netcoreapp1.1 netcoreapp1.1 was computed. netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 is compatible. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 is compatible. |
| .NET Standard | netstandard1.3 netstandard1.3 is compatible. netstandard1.4 netstandard1.4 was computed. netstandard1.5 netstandard1.5 was computed. netstandard1.6 netstandard1.6 was computed. netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net20 net20 is compatible. net35 net35 is compatible. net40 net40 is compatible. net403 net403 was computed. net45 net45 is compatible. net451 net451 was computed. net452 net452 was computed. net46 net46 was computed. net461 net461 is compatible. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 is compatible. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen30 tizen30 was computed. tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Universal Windows Platform | netcore50 netcore50 is compatible. uap uap was computed. uap10.0 uap10.0 is compatible. uap10.0.15138 uap10.0.15138 is compatible. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 3 NuGet packages that depend on AdvancedSharpAdbClient:
| Package | Downloads |
|---|---|
|
ObtSDK
AUTOMATION Android SDK By OBT |
|
|
TaiwanCaptain.God.AdbTool
godlike adb wrapper |
|
|
NightTeam.Conductor
SDK for connecting agents to Conductor server. Provides real-time SignalR communication, TCP, UDP, SSH, Serial, ADB, and Firebase capabilities. 24/7 device automation and control. |
Showing the top 7 popular GitHub repositories that depend on AdvancedSharpAdbClient:
| Repository | Stars |
|---|---|
|
shrimqy/Sefirah
Phone Link / KDE Connect alternative
|
|
|
Paving-Base/APK-Installer
An Android Application Installer for Windows
|
|
|
Macro-Deck-App/Macro-Deck
Macro Deck is the open-source, customizable macro pad for your PC and mobile devices. Ideal for streamers, gamers, developers and power users!
|
|
|
Alex4SSB/ADB-Explorer
A fluent UI for ADB on Windows
|
|
|
TheAirBlow/HyperSploit
Bypasses HyperOS restrictions on bootloader unlocking
|
|
| nerdunit/androidsideloader | |
|
prosthetichead/GarlicPress
GarlicPress is a companion application for the RG35xx running GarlicOS. The main aim of the application is to never require you to remove the SDCards from your device.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.6.16 | 11,079 | 1/13/2026 |
| 3.5.15 | 2,915 | 12/8/2025 |
| 3.4.14 | 44,034 | 3/7/2025 |
| 3.3.13 | 77,959 | 7/30/2024 |
| 3.3.12 | 13,984 | 4/17/2024 |
| 3.2.11 | 4,313 | 3/20/2024 |
| 3.1.10 | 2,782 | 2/21/2024 |
| 3.0.9 | 99,029 | 1/1/2024 |
| 2.5.8 | 2,189 | 10/29/2023 |
| 2.5.7 | 11,786 | 7/10/2023 |
| 2.5.6 | 959 | 5/27/2023 |
| 2.5.5 | 92,278 | 4/4/2023 |
| 2.5.4 | 8,808 | 1/30/2023 |
| 2.5.3 | 850 | 12/21/2022 |
| 2.5.2 | 7,267 | 11/29/2021 |
| 2.5.1 | 844 | 9/29/2021 |
| 2.5.0 | 787 | 9/27/2021 |
| 1.3.0-g | 553 | 9/26/2021 |