{"id":13483701,"url":"https://github.com/mobile-dev-inc/dadb","last_synced_at":"2025-05-14T16:14:14.700Z","repository":{"id":37820322,"uuid":"403788513","full_name":"mobile-dev-inc/dadb","owner":"mobile-dev-inc","description":"A Kotlin/Java library to connect directly to an Android device without an adb binary or an ADB server","archived":false,"fork":false,"pushed_at":"2025-01-14T22:44:57.000Z","size":396,"stargazers_count":1081,"open_issues_count":21,"forks_count":82,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-13T01:56:16.102Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/mobile-dev-inc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","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}},"created_at":"2021-09-07T00:06:15.000Z","updated_at":"2025-04-08T19:50:31.000Z","dependencies_parsed_at":"2023-12-31T22:49:37.285Z","dependency_job_id":"ad80ea97-265f-437f-aa59-821aa95969e8","html_url":"https://github.com/mobile-dev-inc/dadb","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobile-dev-inc%2Fdadb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobile-dev-inc%2Fdadb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobile-dev-inc%2Fdadb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobile-dev-inc%2Fdadb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mobile-dev-inc","download_url":"https://codeload.github.com/mobile-dev-inc/dadb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654050,"owners_count":21140235,"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","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":[],"created_at":"2024-07-31T17:01:14.337Z","updated_at":"2025-04-13T01:56:21.927Z","avatar_url":"https://github.com/mobile-dev-inc.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# dadb\n\n[![Maven Central](https://img.shields.io/maven-central/v/dev.mobile/dadb.svg)](https://mvnrepository.com/artifact/dev.mobile/dadb)\n\n[Blog Post: Our First Open-Source Project](https://blog.mobile.dev/our-first-open-source-project-54cd8edc452f)\n\n\u003cimg src=\"https://user-images.githubusercontent.com/847683/143626125-5872bdd8-180e-48bb-a64f-47b3688a086d.png\" width=\"700px\" /\u003e\n\nA Kotlin/Java library to connect directly to an Android device without an adb binary or an ADB server\n\n```kotlin\ndependencies {\n  implementation(\"dev.mobile:dadb:\u003cversion\u003e\")\n}\n```\n\n### Example Usage\n\nConnect to `emulator-5554` and install `apkFile`:\n\n```kotlin\nDadb.create(\"localhost\", 5555).use { dadb -\u003e\n    dadb.install(apkFile)\n}\n```\n\n*Note: Connect to the odd adb daemon port (5555), not the even emulator console port (5554)*\n\n### Discover a Device\n\nThe following discovers and returns a connected device or emulator. If there are multiple it returns the first one found.\n\n```kotlin\nval dadb = Dadb.discover()\nif (dadb == null) throw RuntimeException(\"No adb device found\")\n```\n\nUse the following API if you want to list all available devices:\n\n```kotlin\nval dadbs = Dadb.list()\n```\n\n### Connecting to a physical device\n\n*Prerequisite: Connecting to a physical device requires a running adb server. In most cases, this means that you must have the `adb` binary installed on your machine.*\n\nThe `Dadb.discover()` and `Dadb.list()` methods now both support USB-connected devices.\n\n```kotlin\n// Both of these will include any USB-connected devices if they are available\nval dadb = Dadb.discover()\nval dadbs = Dadb.list()\n```\n\nIf you'd like to connect directly to a physical device via its serial number. Use the following API:\n\n```kotlin\nval dadb = AdbServer.createDadb(\n    adbServerHost = \"localhost\",\n    adbServerPort = 5037,\n    deviceQuery = \"host:transport:${serialNumber}\"\n)\n```\n\n### Install / Uninstall APK\n\n```kotlin\ndadb.install(exampleApkFile)\ndadb.uninstall(\"com.example.app\")\n```\n\n### Push / Pull Files\n\n```kotlin\ndadb.push(srcFile, \"/data/local/tmp/dst.txt\")\ndadb.pull(dstFile, \"/data/local/tmp/src.txt\")\n```\n\n### Execute Shell Command\n\n```kotlin\nval response = dadb.shell(\"echo hello\")\nassert(response.exitCode == 0)\nassert(response.output == \"hello\\n\")\n```\n\n### TCP Forwarding\n\n```kotlin\ndadb.tcpForward(\n    hostPort = 7001,\n    targetPort = 7001\n).use {\n    // localhost:7001 is now forwarded to device's 7001 port\n    // Do operations that depend on port forwarding\n}\n```\n\n### Authentication\n\n**Dadb will use your adb key at `~/.android/adbkey` by default. If none exists at this location, private and public keys will be generated by dadb.**\n\nIf you need to specify a custom path to your adb key, use the optional `keyPair` argument:\n\n```kotlin\nval adbKeyPair = AdbKeyPair.read(privateKeyFile, publicKeyFile)\nDadb.create(\"localhost\", 5555, adbKeyPair)\n```\n\n# License\n\n```\nCopyright (c) 2021 mobile.dev inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobile-dev-inc%2Fdadb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmobile-dev-inc%2Fdadb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobile-dev-inc%2Fdadb/lists"}