{"id":18376824,"url":"https://github.com/bbc/device_api-android","last_synced_at":"2026-03-02T11:32:59.399Z","repository":{"id":20119854,"uuid":"23389720","full_name":"bbc/device_api-android","owner":"bbc","description":"DeviceAPI-Android","archived":false,"fork":false,"pushed_at":"2020-07-27T23:21:32.000Z","size":250,"stargazers_count":19,"open_issues_count":4,"forks_count":3,"subscribers_count":12,"default_branch":"master","last_synced_at":"2026-02-18T19:18:19.439Z","etag":null,"topics":["adb","android","deviceapi"],"latest_commit_sha":null,"homepage":"http://bbc.github.io/hive-ci/test-tools.html","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bbc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-27T12:59:11.000Z","updated_at":"2024-04-12T20:58:15.000Z","dependencies_parsed_at":"2022-08-30T10:50:56.661Z","dependency_job_id":null,"html_url":"https://github.com/bbc/device_api-android","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/bbc/device_api-android","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fdevice_api-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fdevice_api-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fdevice_api-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fdevice_api-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbc","download_url":"https://codeload.github.com/bbc/device_api-android/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fdevice_api-android/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30000029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T11:09:27.951Z","status":"ssl_error","status_checked_at":"2026-03-02T11:08:53.255Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","deviceapi"],"created_at":"2024-11-06T00:24:53.613Z","updated_at":"2026-03-02T11:32:59.367Z","avatar_url":"https://github.com/bbc.png","language":"Ruby","readme":"# DeviceAPI-Android\n[![Build Status](https://travis-ci.org/bbc/device_api-android.svg?branch=master)](https://travis-ci.org/bbc/device_api-android)\n\n*DeviceAPI-Android* is the android implementation of device_api -- an initiative to allow full automation of device activities. For a full list of release notes, see the [change log](CHANGELOG.md)\n\n## Dependencies\n\ndevice_api-android shells out to a number of android command line tools. You will need to make sure the android sdk is installed and you have the following commands on your path:\n\n* adb\n* aapt\n\n## Using the gem\n\nAdd the device_api-android gem to your gemfile -- this will automatically bring in the device_api base gem on which the android gem is built.\n\n    gem 'device_api-android'\n  \nYou'll need to require the library in your code:\n\n    require 'device_api/android'\n\nTry connecting an android device with usb, and run:\n\n    devices = DeviceAPI::Android.devices\n\nYou might need to set your device to developer mode, and turn on usb debugging so that the android debug bridge can detect your device.\n\n### Connecting and disconnecting from Remote Devices\n\nYou can connect to devices via their IP address and port number. The syntax is:\n\n    DeviceAPI::Android.connect(\u003cIP address\u003e,\u003cport number\u003e=5555)\n\nThis should add a device to the already connected devices, which you can query with DeviceAPI::Android.devices. You can disconnect from a device like so:\n\n    DeviceAPI::Android.disconnect(\u003cIP address\u003e,\u003cport number\u003e=5555)\n\nOnce connected, the IP address and port number combination becomes the serial for the device, and you can execute commands such as adb shell through specifying the IP address/port number instead of the serial number. For both Android.connect and Android.disconnect, if port number is not specified, and ip address is only specified, port number defaults to 5555. (Note that Android.disconnect doesn't automagically disconnect you from a connection with a port number that is not 5555 when it is called without a port argument)\n\nYou can also use the disconnect method on a Android device object, without any arguments to disconnect a device. It will throw an error if the device is not connected. \n\n    device.disconnect\n\nYou can use device.is_remote? to determine if the device is a remote device, e.g. it has a ipaddress and port as an adb serial, and can attempt to be connected to.\n\n    device.is_remote?\n\n### Error messages\n\nHere are some of the errors you may encounter as well as a example of what can cause them:\n\n`DeviceAPI::Android::ADB::DeviceAlreadyConnectedError` - raised when DeviceAPI::Android.connect is called on an currently connected device.\n\n`DeviceAPI::Android::DeviceDisconnectedWhenNotARemoteDevice` - raised when we are attempting to call disconnect on a non-remote device.\n\n`DeviceAPI::Android::ADBCommandError` - raised when we cannot connect to a device, e.g. adb times out.\n\n### Detecting devices\n\nThere are two methods for detecting devices:\n\n    DeviceAPI::Android.devices \n\nThis returns an array of objects representing the connected devices. You get an empty array if there are no connected devices.\n\n    DeviceAPI::Android.device(serial_id)\n    \nThis looks for a device with a matching serial_id and returns a single device object.\n\n### Device object\n\nWhen device-api detects a device, it returns a device object that lets you interact with and query the device with various android tools.\n\nFor example:\n\n    device = DeviceAPI::Android.device(serial_id)\n    device.serial # \"01498A0004005015\"\n    device.model # \"Galaxy Nexus\"\n\n#### Device orientation\n\n    device.orientation # :landscape / :portrait\n\n#### Install/uninstall apk\n\n    device.install('location/apk_to_install.apk') # will install the apk on the device\n    device.uninstall('my.package.name') # will uninstall the package matching the package name\n\n#### APK Signing\n\nAn APK can be signed using *DeviceAPI*. To do so you can simply run:\n\n    DeviceAPI::Android::Signing.sign_apk({apk: apk_path, resign: true})\n\nIf you don't already have a keystore setup then one will be created for you with some defaults already set. If you wish to setup a keystore using your own options you can do so using something like the following:\n\n    DeviceAPI::Android::Signing.generate_keystore( { keystore: '~/new_kestore.keystore', password: 'new_password' } )\n\nThis allows you to setup a keystore with the options required by any testing framework\n\n### Package details\n\n    device.package_name('app.apk') # returns some.package.name\n    device.app_version_number('app.apk') # returns v#.#.#\n\n## Testing\n\ndevice_api-android is defended with unit and integration level rspec tests. You can run the tests with:\n\n    bundle exec rspec\n\n## Issues\n\nIf you plug in a device and adb shows the device as having no permissions as seen here:\n\n            hive@hive-04:~$ adb devices\n            List of devices attached\n            ????????????\tno permissions\n\nThis is caused by the current user not having permission to access the USB interface. To resolve this, copy the 51-android.rules file to the /etc/udev/rules.d/ directory and restart adb by using the folliowing command\n\n            adb kill-server\n            adb start-server\n\nIf, after copying the rules file to the correct location, you're still seeing the no permission message it may be due to the fact that the device does not have a rule setup for it. To add a new rule, type:\n\n            lsusb\n\nYou should be presented with something similar to this:\n\n            Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub\n            Bus 001 Device 020: ID 0e79:5009 Archos, Inc.\n            Bus 001 Device 003: ID 05ac:8242 Apple, Inc. Built-in IR Receiver\n            Bus 001 Device 006: ID 05ac:8289 Apple, Inc.\n            Bus 001 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)\n            Bus 001 Device 011: ID 05c6:6765 Qualcomm, Inc.\n            Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub\n            \nThe important thing to note here is the Vendor ID and Product ID for the device. In the case of the above, the device is a Tesco Hudl (showing as an Archos device) with the combined ID of 0e79:5009 - 0e79 is the Vendor ID while 5009 is the Product ID. Open the 51-android.rules file and add the following line:\n\n            SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0e79\", ATTR{idProduct}==\"5009\", MODE=\"0666\", OWNER=\"hive\"\n\nChange the Vendor and Product IDs where appropriate, also check that the owner matches the name of the account that will be running the Hive.\n\n## License\n\n*DeviceAPI-Android* is available to everyone under the terms of the MIT open source licence. Take a look at the LICENSE file in the code.\n\nCopyright (c) 2016 BBC\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbc%2Fdevice_api-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbc%2Fdevice_api-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbc%2Fdevice_api-android/lists"}