Android platform commands for React Native CLI providing run-android, build-android, and log-android commands for managing Android development workflow
—
Android emulator lifecycle management including discovery, launching, availability checking, and automated emulator selection for React Native development.
Functions for discovering and listing available Android emulators on the development system.
/**
* Get list of available Android emulators
* Scans the Android SDK for configured emulator instances
* @returns Array of emulator names
*/
function getEmulators(): string[];Note: This function is internal and not directly exportable from the main package.
Automated emulator launching with success/failure reporting and optional port configuration.
/**
* Attempt to launch Android emulator
* @param adbPath - Path to ADB executable
* @param emulatorName - Optional specific emulator name to launch
* @param port - Optional port number for emulator
* @returns Promise resolving to launch result with success status and error details
*/
async function tryLaunchEmulator(
adbPath: string,
emulatorName?: string,
port?: number
): Promise<{success: boolean; error?: string}>;Launch Result Interface:
interface EmulatorLaunchResult {
/** Whether emulator launch was successful */
success: boolean;
/** Error message if launch failed */
error?: string;
}Note: This function is internal and not directly exportable from the main package. It's used internally by the run-android command for automatic emulator launching.
/**
* Launch specific emulator instance
* Internal function for emulator launching with detailed configuration
* @param emulatorName - Name of emulator to launch
* @param adbPath - Path to ADB executable
* @param port - Optional port number for emulator instance
* @returns Promise resolving to true if launch successful
*/
async function launchEmulator(emulatorName: string, adbPath: string, port?: number): Promise<boolean>;The getEmulators() function:
$ANDROID_HOME/avd/ directoryThe tryLaunchEmulator() function implements a comprehensive launch process:
When no specific emulator is provided:
Emulator port management:
The launch process includes:
The emulator management system handles various failure scenarios:
Error messages provide actionable information:
const result = await tryLaunchEmulator(adbPath, "invalid-emulator");
if (!result.success) {
// result.error contains specific failure reason:
// "Emulator 'invalid-emulator' not found"
// "Android SDK not configured properly"
// "Insufficient system resources"
// "Port 5554 is already in use"
}When using React Native CLI commands:
Emulator management integrates seamlessly with development workflows:
Usage in Development Scripts:
import { getEmulators, tryLaunchEmulator, getAdbPath } from "@react-native-community/cli-platform-android";
async function setupDevelopmentEnvironment() {
const adbPath = getAdbPath();
const emulators = getEmulators();
if (emulators.length === 0) {
console.error("No emulators configured. Please create an AVD first.");
return;
}
// Launch first available emulator
const result = await tryLaunchEmulator(adbPath, emulators[0]);
if (result.success) {
console.log(`Development emulator ${emulators[0]} is ready`);
} else {
console.error(`Failed to launch emulator: ${result.error}`);
}
}Install with Tessl CLI
npx tessl i tessl/npm-react-native-community--cli-platform-android