{"id":33023118,"url":"https://github.com/SharpAdb/AdvancedSharpAdbClient","last_synced_at":"2025-11-24T23:30:13.964Z","repository":{"id":39625091,"uuid":"410572246","full_name":"SharpAdb/AdvancedSharpAdbClient","owner":"SharpAdb","description":"AdvancedSharpAdbClient is a .NET library that allows .NET, Mono and Unity applications to communicate with Android devices. It's improved version of SharpAdbClient.","archived":false,"fork":false,"pushed_at":"2025-11-12T06:16:17.000Z","size":6631,"stargazers_count":275,"open_issues_count":24,"forks_count":65,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-11-12T08:18:29.137Z","etag":null,"topics":["adb","android","csharp","dotnet","mono","unity","uwp"],"latest_commit_sha":null,"homepage":"https://sharpadb.github.io","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SharpAdb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-09-26T14:21:08.000Z","updated_at":"2025-11-11T05:30:13.000Z","dependencies_parsed_at":"2023-09-22T21:14:59.549Z","dependency_job_id":"7ceff30d-7c35-4254-a5a0-9aeff474ce0f","html_url":"https://github.com/SharpAdb/AdvancedSharpAdbClient","commit_stats":{"total_commits":105,"total_committers":9,"mean_commits":"11.666666666666666","dds":0.2761904761904762,"last_synced_commit":"e33b09be35f1b1bb9c6563408edf44e2c334173c"},"previous_names":["sharpadb/advancedsharpadbclient","yungd1plomat/advancedsharpadbclient"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/SharpAdb/AdvancedSharpAdbClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SharpAdb%2FAdvancedSharpAdbClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SharpAdb%2FAdvancedSharpAdbClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SharpAdb%2FAdvancedSharpAdbClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SharpAdb%2FAdvancedSharpAdbClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SharpAdb","download_url":"https://codeload.github.com/SharpAdb/AdvancedSharpAdbClient/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SharpAdb%2FAdvancedSharpAdbClient/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286079811,"owners_count":27282121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-24T02:00:07.096Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adb","android","csharp","dotnet","mono","unity","uwp"],"created_at":"2025-11-13T19:00:34.935Z","updated_at":"2025-11-24T23:30:13.958Z","avatar_url":"https://github.com/SharpAdb.png","language":"C#","funding_links":[],"categories":["Game-BenchMark/Metric/Tool"],"sub_categories":[],"readme":"| Issues | License | NuGet |\n|--------|---------|-------|\n[![Github Issues](https://img.shields.io/github/issues/SharpAdb/AdvancedSharpAdbClient)](https://github.com/SharpAdb/AdvancedSharpAdbClient/issues)|[![License](https://img.shields.io/github/license/SharpAdb/AdvancedSharpAdbClient)](https://github.com/SharpAdb/AdvancedSharpAdbClient/blob/main/LICENSE)|[![NuGet Status](https://img.shields.io/nuget/dt/AdvancedSharpAdbClient.svg?style=flat)](https://www.nuget.org/packages/AdvancedSharpAdbClient/)\n\n# A .NET client for adb, the Android Debug Bridge (AdvancedSharpAdbClient)\n\nAdvancedSharpAdbClient is a .NET library that allows .NET applications to communicate with Android devices. \nIt provides a .NET implementation of the `adb` protocol, giving more flexibility to the developer than launching an \n`adb.exe` process and parsing the console output.\n\nIt's upgraded version of [SharpAdbClient](https://github.com/quamotion/madb).\nAdded important features.\n\n## Support Platform\n- .NET Framework 2.0 (Without Task)\n- .NET Framework 3.5\n- .NET Framework 4.0 (Need [Microsoft.Bcl.Async](https://www.nuget.org/packages/Microsoft.Bcl.Async))\n- .NET Framework 4.5\n- .NET Framework 4.6.1\n- .NET Framework 4.8\n- .NET Standard 1.3\n- .NET Standard 2.0\n- .NET Standard 2.1\n- .NET Core 5.0 (Support UAP 10.0 and UAP 10.0.15138.0)\n- .NET Core App 2.1\n- .NET Core App 3.1\n- .NET 6.0\n- .NET 8.0\n\n## Installation\nTo install AdvancedSharpAdbClient install the [AdvancedSharpAdbClient NuGetPackage](https://www.nuget.org/packages/AdvancedSharpAdbClient). If you're\nusing Visual Studio, you can run the following command in the [Package Manager Console](http://docs.nuget.org/consume/package-manager-console):\n\n```ps\nPM\u003e Install-Package AdvancedSharpAdbClient\n```\n\n## Getting Started\nAdvancedSharpAdbClient 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.\n\nYou 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:\n\n```cs\nif (!AdbServer.Instance.GetStatus().IsRunning)\n{\n    AdbServer server = new AdbServer();\n    StartServerResult result = server.StartServer(@\"C:\\adb\\adb.exe\", false);\n    if (result != StartServerResult.Started)\n    {\n        Console.WriteLine(\"Can't start adb server\");\n    }\n}\n```\n\n### Connecting to device\nBefore using all the methods, you must initialize the new AdbClient class and then connect to the device\n\nIf you want to automate 2 or more devices at the same time, you must remember: 1 device - 1 AdbClient class\n\nYou can look at the examples to understand more\n\n```cs\nstatic AdbClient adbClient;\nstatic DeviceData deviceData;\n\nstatic void Main(string[] args)\n{\n    adbClient = new AdbClient();\n    adbClient.Connect(\"127.0.0.1:62001\");\n    device = adbClient.GetDevices().FirstOrDefault(); // Get first connected device\n    ...\n}\n```\n\n## Device automation\n\n### Finding element\nYou can find the element on the screen by xpath\n\n```cs\nstatic DeviceClient deviceClient;\n\nstatic void Main(string[] args)\n{\n    ...\n    deviceClient = new DeviceClient(adbClient, deviceData);\n    Element element = deviceClient.FindElement(\"//node[@text='Login']\");\n    ...\n}\n```\n\nYou can also specify the waiting time for the element\n\n```cs\nElement element = deviceClient.FindElement(\"//node[@text='Login']\", TimeSpan.FromSeconds(5));\n```\n\nAnd you can find several elements\n\n```cs\nElement[] element = deviceClient.FindElements(\"//node[@resource-id='Login']\", TimeSpan.FromSeconds(5));\n```\n\n### Getting element attributes\nYou can get all element attributes\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    Element element = deviceClient.FindElement(\"//node[@resource-id='Login']\", TimeSpan.FromSeconds(3));\n    string eltext = element.Attributes[\"text\"];\n    string bounds = element.Attributes[\"bounds\"];\n    ...\n}\n```\n\n\n### Clicking on an element\nYou can click on the x and y coordinates\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    deviceClient.Click(600, 600); // Click on the coordinates (600;600)\n    ...\n}\n```\n\nOr on the element(need xpath)\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    Element element = deviceClient.FindElement(\"//node[@text='Login']\", TimeSpan.FromSeconds(3));\n    element.Click(); // Click on element by xpath //node[@text='Login']\n    ...\n}\n```\n\nThe Click() method throw ElementNotFoundException if the element is not found\n\n```cs\ntry\n{\n    element.Click();\n}\ncatch (Exception ex)\n{\n    Console.WriteLine($\"Can't click on the element:{ex.Message}\");\n}\n```\n\n\n### Swipe\nYou can swipe from one element to another\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    Element first = deviceClient.FindElement(\"//node[@text='Login']\");\n    Element second = deviceClient.FindElement(\"//node[@text='Password']\");\n    deviceClient.Swipe(first, second, 100); // Swipe 100 ms\n    ...\n}\n```\n\nOr swipe by coordinates\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    deviceClient.Swipe(600, 1000, 600, 500, 100); // Swipe from (600;1000) to (600;500) on 100 ms\n    ...\n}\n```\n\nThe Swipe() method throw ElementNotFoundException if the element is not found\n\n```cs\ntry\n{\n    deviceClient.Swipe(0x2232323, 0x954, 0x9128, 0x11111, 200);\n    ...\n    deviceClient.Swipe(first, second, 200);\n}\ncatch (Exception ex)\n{\n    Console.WriteLine($\"Can't swipe:{ex.Message}\");\n}\n```\n\n\n### Send text\nYou can send any text except Cyrillic (Russian isn't supported by adb)\n\nThe text field should be in focus\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    deviceClient.SendText(\"text\"); // Send text to device\n    ...\n}\n```\n\nYou can also send text to the element (clicks on the element and sends the text)\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    deviceClient.FindElement(\"//node[@resource-id='Login']\").SendText(\"text\"); // Send text to the element by xpath //node[@resource-id='Login']\n    ...\n}\n```\n\nThe SendText() method throw InvalidTextException if text is incorrect\n\n```cs\ntry\n{\n    deviceClient.SendText(null);\n}\ncatch (Exception ex)\n{\n    Console.WriteLine($\"Can't send text:{ex.Message}\");\n}\n```\n\n\n### Clearing the input text\n\nYou can clear text input\n\nThe text field should be in focus\n\n**Recommended**\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    deviceClient.ClearInput(25); // The argument is to specify the maximum number of characters to be erased\n    ...\n}\n```\n\n**It may work unstable**\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    deviceClient.FindElement(\"//node[@resource-id='Login']\").ClearInput(); // Get element text attribute and remove text length symbols\n    ...\n}\n```\n\n### Sending key events\n\nYou can see key events here https://developer.android.com/reference/android/view/KeyEvent#constants\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    deviceClient.SendKeyEvent(\"KEYCODE_TAB\");\n    ...\n}\n```\n\nThe SendKeyEvent method throw InvalidKeyEventException if key event is incorrect\n\n```cs\ntry\n{\n    deviceClient.SendKeyEvent(null);\n}\ncatch (Exception ex)\n{\n    Console.WriteLine($\"Can't send keyevent:{ex.Message}\");\n}\n```\n\n### BACK and HOME buttons\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    deviceClient.ClickBackButton(); // Click Back button\n    ...\n    deviceClient.ClickHomeButton(); // Click Home button\n    ...\n}\n```\n\n## Device commands\n**Some commands require Root**\n### Install and Uninstall applications\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    PackageManager manager = new PackageManager(adbClient, deviceData);\n    manager.InstallPackage(@\"C:\\Users\\me\\Documents\\mypackage.apk\");\n    manager.UninstallPackage(\"com.android.app\");\n    ...\n}\n```\n\nOr you can use AdbClient.Install\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    using (FileStream stream = File.OpenRead(\"Application.apk\"))\n    {\n        adbClient.Install(device, stream);\n        adbClient.Uninstall(device, \"com.android.app\");\n    }\n    ...\n}\n```\n### Install multiple applications\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    PackageManager manager = new PackageManager(adbClient, deviceData);\n    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\n    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'\n    ...\n}\n```\n\nOr you can use AdbClient.InstallMultiple\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    adbClient.InstallMultiple(device, File.OpenRead(\"base.apk\"), new[] { File.OpenRead(\"split_1.apk\"), File.OpenRead(\"split_2.apk\") }); // Install split app whith base app\n    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'\n    ...\n}\n```\n\n### Start and stop applications\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    deviceClient.StartApp(\"com.android.app\");\n    deviceClient.StopApp(\"com.android.app\"); // force-stop\n    ...\n}\n```\n\n### Getting a screenshot\n\n```cs\nstatic async void Main(string[] args)\n{\n    ...\n    Image img = adbClient.GetFrameBuffer(deviceData, CancellationToken.None); // synchronously\n    ...\n    Image img = await adbClient.GetFrameBufferAsync(deviceData, CancellationToken.None); // asynchronously\n    ...\n}\n```\n\n### Getting screen xml hierarchy\n\n```cs\nstatic void Main(string[] args)\n{\n    ...\n    XmlDocument screen = deviceClient.DumpScreen();\n    ...\n}\n```\n\n### Send or receive files\n\n```cs\nvoid DownloadFile()\n{\n    using (SyncService service = new SyncService(deviceData))\n    {\n        using (FileStream stream = File.OpenWrite(@\"C:\\MyFile.txt\"))\n        {\n            service.Pull(\"/data/local/tmp/MyFile.txt\", stream, null);\n        }\n    }\n}\n\nvoid UploadFile()\n{\n    using (SyncService service = new SyncService(deviceData))\n    {\n        using (FileStream stream = File.OpenRead(@\"C:\\MyFile.txt\"))\n        {\n            service.Push(stream, \"/data/local/tmp/MyFile.txt\", UnixFileStatus.DefaultFileMode, DateTimeOffset.Now, null);\n        }\n    }\n}\n```\n\n### Run shell commands\n\n```cs\nstatic async void Main(string[] args)\n{\n    ...\n    ConsoleOutputReceiver receiver = new ConsoleOutputReceiver();\n    adbClient.ExecuteRemoteCommand(\"echo Hello, World\", device, receiver); // synchronously\n    ...\n    await adbClient.ExecuteRemoteCommandAsync(\"echo Hello, World\", device, receiver, default); // asynchronously\n    ...\n}\n```\n\n### Encoding\nDefault encoding is UTF8, if you want to change it, use\n\n```cs\nAdbClient.SetEncoding(Encoding.ASCII);\n```\n\n## Contributors\n[![Contributors](https://contrib.rocks/image?repo=SharpAdb/AdvancedSharpAdbClient)](https://github.com/SharpAdb/AdvancedSharpAdbClient/graphs/contributors)\n\n## Consulting and Support\nPlease open an [**issue**](https://github.com/SharpAdb/AdvancedSharpAdbClient/issues) on if you have suggestions or problems.\n\n## History\nAdvancedSharpAdbClient is a fork of [SharpAdbClient](https://github.com/quamotion/madb) and [madb](https://github.com/camalot/madb) which in itself is a .NET port of the [ddmlib Java Library](https://android.googlesource.com/platform/tools/base/+/master/ddmlib/).\n\nCredits:\nhttps://github.com/camalot, https://github.com/quamotion","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSharpAdb%2FAdvancedSharpAdbClient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSharpAdb%2FAdvancedSharpAdbClient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSharpAdb%2FAdvancedSharpAdbClient/lists"}