qiqi-adbkit
TypeScript icon, indicating that this package has built-in type declarations

1.1.6 • Public • Published

adbkit

adbkit is a pure Node.js client for the Android Debug Bridge server. It can be used either as a library in your own application, or simply as a convenient utility for playing with your device.

Most of the adb command line tool's functionality is supported (including pushing/pulling files, installing APKs and processing logs), with some added functionality such as being able to generate touch/key events and take screenshots. Some shims are provided for older devices, but we have not and will not test anything below Android 2.3.

Internally, we use this library to drive a multitude of Android devices from a variety of manufacturers, so we can say with a fairly high degree of confidence that it will most likely work with your device(s), too.

Requirements

  • Node.js >= 14
  • The adb command line tool

Please note that although it may happen at some point, this project is NOT an implementation of the ADB server. The target host (where the devices are connected) must still have ADB installed and either already running (e.g. via adb start-server) or available in $PATH. An attempt will be made to start the server locally via the aforementioned command if the initial connection fails. This is the only case where we fall back to the adb binary.

When targeting a remote host, starting the server is entirely your responsibility.

Alternatively, you may want to consider using the Chrome ADB extension, as it includes the ADB server and can be started/stopped quite easily.

For Linux users, adb need plugdev group acess, So you may need to add your current user to plugdev group. sudo usermod -a -G plugdev $USER

Getting started

Install via NPM:

npm install --save @u4/adbkit

We use debug, and our debug namespace is adb. Some of the dependencies may provide debug output of their own. To see the debug output, set the DEBUG environment variable. For example, run your program with DEBUG=adb:* node app.js.

Getting started sample

import { createClient } from '@u4/adbkit';

const main = async () => {
  const adbClient = createClient();
  const devices = await adbClient.listDevices();
  if (!devices.length) {
    console.error('Need at least one connected android device');
    return;
  }
  // deviceClient is a DeviceClient
  const deviceClient = devices[0].getClient();
  // your device is ready to use
  // check all DeviceClient functions
  // print Hello Word in a shell and get the echo back
  const hello = await deviceClient.execOut('echo Hello Word', 'utf8');
  console.log(hello)
}

full documentaion is available here

Incompatible changes in version 3.x

  • Previously, adbKit was based on Bluebird, It's now based on native Promise some Bluebird Promise cannelation is not compatible with ES6 Promises.
  • v4 is Object oriented functions taking a serial as first parameter had been moved to DeviceClient

More information

Contributing

See CONTRIBUTING.md.

License

See LICENSE.

@yume-chan/adb a browser adb implementation

Package Sidebar

Install

npm i qiqi-adbkit

Weekly Downloads

1

Version

1.1.6

License

Apache-2.0

Unpacked Size

2.57 MB

Total Files

495

Last publish

Collaborators

  • iamqiqi1017