Android platform commands for React Native CLI providing run-android, build-android, and log-android commands for managing Android development workflow
—
ADB integration for discovering, selecting, and managing Android devices and emulators. Provides comprehensive device detection, interactive selection, and device capability analysis.
Core ADB interaction utilities for device discovery and hardware information.
/**
* ADB utilities object with device management functions
*/
const adb: {
/** Get list of connected devices from ADB */
getDevices: (adbPath: string) => Array<string>;
/** Get available CPU architectures from device */
getAvailableCPUs: (adbPath: string, device: string) => Array<string>;
/** Get primary CPU architecture of device */
getCPU: (adbPath: string, device: string) => string | null;
};
// Note: Individual ADB functions are only accessible through the adb object above.
// parseDevicesResult is an internal function not exported separately.Usage Examples:
import { adb, getAdbPath } from "@react-native-community/cli-platform-android";
const adbPath = getAdbPath();
// Get all connected devices
const devices = adb.getDevices(adbPath);
console.log("Connected devices:", devices);
// Get CPU architecture for first device
if (devices.length > 0) {
const cpu = adb.getCPU(adbPath, devices[0]);
console.log(`Device ${devices[0]} CPU:`, cpu);
// Get all available CPUs
const availableCPUs = adb.getAvailableCPUs(adbPath, devices[0]);
console.log("Available CPUs:", availableCPUs);
}Utility for locating the ADB executable in the system.
/**
* Get path to ADB executable
* Uses ANDROID_HOME environment variable if available
* @returns Path to ADB executable
*/
function getAdbPath(): string;Usage Examples:
import { getAdbPath } from "@react-native-community/cli-platform-android";
// Get ADB path for system operations
const adbPath = getAdbPath();
console.log("ADB located at:", adbPath);Interactive device selection with emulator and phone detection.
/**
* Interactive device selection with emulator/phone detection
* @returns Promise resolving to selected device data or undefined if cancelled
*/
async function listAndroidDevices(): Promise<DeviceData | undefined>;
/**
* Device information structure
*/
interface DeviceData {
/** Device identifier (can be undefined for offline devices) */
deviceId: string | undefined;
/** Human-readable device name */
readableName: string;
/** Whether device is currently connected */
connected: boolean;
/** Device type classification */
type: 'emulator' | 'phone';
}
/**
* Get readable name for Android emulator
* @param deviceId - Emulator device identifier
* @returns Human-readable emulator name
*/
function getEmulatorName(deviceId: string): string;
/**
* Get readable name for physical Android device
* @param deviceId - Physical device identifier
* @returns Human-readable device name
*/
function getPhoneName(deviceId: string): string;
/**
* Interactive prompt for device selection from available devices
* @param allDevices - Array of available devices
* @returns Promise resolving to selected device or undefined if cancelled
*/
function promptForDeviceSelection(allDevices: Array<DeviceData>): Promise<DeviceData | undefined>;Usage Examples:
import { listAndroidDevices } from "@react-native-community/cli-platform-android";
// Interactive device selection
const selectedDevice = await listAndroidDevices();
if (selectedDevice) {
console.log(`Selected device: ${selectedDevice.readableName}`);
console.log(`Device ID: ${selectedDevice.deviceId}`);
console.log(`Type: ${selectedDevice.type}`);
console.log(`Connected: ${selectedDevice.connected}`);
} else {
console.log("No device selected");
}Support for Android devices with multiple user profiles.
/**
* User profile information for multi-user devices
*/
interface User {
/** User profile ID */
id: string;
/** User profile display name */
name: string;
}
/**
* Get available user profiles on device (Internal Function)
* Note: This function is internal and not directly exportable from the main package
* @param device - Device identifier
* @param adbPath - Path to ADB executable
* @returns Array of available user profiles
*/
function checkUsers(device: string, adbPath: string): User[];
/**
* Interactive prompt for user profile selection (Internal Function)
* Note: This function is internal and not directly exportable from the main package
* @param users - Array of available user profiles
* @returns Promise resolving to selected user profile
*/
async function promptForUser(users: User[]): Promise<User>;Note: These functions are internal and used by the CLI commands for multi-user device support. They are not directly importable from the main package.
/**
* Get readable name for Android emulator
* @param deviceId - Emulator device identifier
* @returns Human-readable emulator name
*/
function getEmulatorName(deviceId: string): string;
/**
* Get readable name for physical Android device
* @param deviceId - Physical device identifier
* @returns Human-readable device name
*/
function getPhoneName(deviceId: string): string;These functions convert device IDs like "emulator-5554" or "abc123device" into user-friendly names for display in device selection prompts.
Install with Tessl CLI
npx tessl i tessl/npm-react-native-community--cli-platform-android