A modern, powerful TypeScript library for Android Debug Bridge (ADB) operations. This library provides a robust interface to interact with Android devices, offering comprehensive device management, app control, and system monitoring capabilities.
Imagine controlling your Android device with code that's actually readable. No more cryptic ADB commands or shell script nightmares. This library is like having a universal remote for your Android device, but cooler because... well, it's code!
- ๐ Sherlock-Level ADB Detection: Finds your ADB binary faster than you can say "where's my SDK?"
- ๐ฏ TypeScript Superpowers: Because any's are scary and we like our types strict
- ๐ Swiss Army Knife API: Everything you need, nothing you don't
- ๐ฑ Device Whisperer: Talk to your device like never before
- โก Promise-based: Because callbacks are so 2010
- ๐ Type-Safe: Let the compiler catch your "oops" moments
npm install adb-client
# or if you're a yarn person
yarn add adb-client
# or if you're one of those cool pnpm folks
pnpm add adb-client
import { ADB } from 'adb-client';
// Let's do some magic! โจ
async function main() {
try {
const adb = new ADB();
// Find all your Android friends
const devices = await adb.getDevices();
if (devices.length === 0) {
console.log('๐ข No devices found. Did you forget to plug it in?');
return;
}
// Pick your favorite device (or the only one you have ๐
)
const device = devices[0];
console.log(`๐ฏ Found device: ${device.model || 'Mystery Phone'}`);
// Let's take a selfie (screenshot)!
await adb.takeScreenshot(device.serialNumber, './awesome-screenshot.png');
console.log('๐ธ Say cheese!');
} catch (error) {
console.error('๐ฅ Oops!', error.message);
}
}
const adb = new ADB();
// Let's see what devices we've got
const devices = await adb.getDevices();
devices.forEach(device => {
console.log(`๐ฑ Found: ${device.model || 'Mystery Device'} (${device.serialNumber})`);
});
// Get all the juicy details
const props = await adb.getDeviceProperties(devices[0].serialNumber);
console.log(`
๐ค Android Version: ${props.androidVersion}
๐ฆ SDK: ${props.sdkVersion}
โญ Brand: ${props.brand}
`);
// Install that awesome app you built
await adb.installAPK('device123', './my-awesome-app.apk');
// Launch it to the moon! ๐
await adb.startApp('device123', 'com.your.awesome.app', '.MainActivity');
// Check how awesome your app is
const info = await adb.getPackageInfo('device123', 'com.your.awesome.app');
console.log(`๐ App Version: ${info.versionName} (${info.versionCode})`);
// Marie Kondo your app data
await adb.clearAppData('device123', 'com.your.awesome.app');
// Take a screenshot (perfect for those "it works on my machine" moments)
await adb.takeScreenshot('device123', './proof-it-works.png');
// Record a video (great for catching those elusive bugs)
await adb.recordScreen('device123', './bug-in-action.mp4', 10, {
size: '720x1280', // For those who care about quality
bitRate: '4M' // For those who care about file size
});
// Check the battery (is it coffee break time?)
const battery = await adb.getBatteryInfo('device123');
console.log(`
๐ Battery: ${battery.level}%
๐ก๏ธ Temperature: ${battery.temperature}ยฐC
โก Charging: ${battery.isCharging ? 'Yep!' : 'Nope!'}
`);
// Network status (for when Wi-Fi is being sneaky)
const network = await adb.getNetworkInfo('device123');
console.log(`
๐ IP: ${network.ipAddress}
๐ถ Wi-Fi: ${network.wifiEnabled ? 'Connected' : 'Looking for signal...'}
`);
// Press buttons like a pro gamer
await adb.sendKeyEvent('device123', 'KEYCODE_HOME'); // Go home!
await adb.sendKeyEvent('device123', 'KEYCODE_BACK'); // Retreat!
// Toggle Wi-Fi (because why not?)
await adb.setWifiEnabled('device123', true); // ๐ถ ON
await adb.setWifiEnabled('device123', false); // ๐ด OFF
import { ADB, ADBError, DeviceNotFoundError, CommandError } from 'adb-client';
try {
const adb = new ADB();
await adb.getDevices();
} catch (error) {
if (error instanceof DeviceNotFoundError) {
console.error('๐ข Device went on vacation:', error.message);
} else if (error instanceof CommandError) {
console.error('๐ค ADB is being difficult:', error.message);
} else {
console.error('๐ฅ Something went boom:', error);
}
}
const adb = new ADB({
customPath: '/path/to/your/special/adb', // For the special snowflakes
timeout: 5000 // For the impatient developers
});
- Node.js โฅ 18 (Because we're modern like that)
- ADB installed (You knew this was coming, right?)
- An Android device (Or emulator, we don't judge)
- Fork it (Yes, that button up there โ๏ธ)
- Create your feature branch:
git checkout -b feature/something-awesome
- Commit your changes:
git commit -m 'Add something awesome'
- Push to the branch:
git push origin feature/something-awesome
- Submit a PR (and make our day!)
# Get the party started
npm install
# Build something amazing
npm run build
# Make sure it works
npm test
# Make it pretty
npm run format
MIT License - Go wild! (Just don't blame us if something breaks ๐)
Found a bug? Got a cool idea? Need a virtual hug?
- Open an issue
- Submit a PR
- Send a carrier pigeon
- Telepathic device control
- Time travel debugging
- Coffee maker integration
- More realistic features we're actually working on...
Made with โ and TypeScript. Happy coding! ๐