Android platform commands for React Native CLI providing run-android, build-android, and log-android commands for managing Android development workflow
npx @tessl/cli install tessl/npm-react-native-community--cli-platform-android@20.0.0React Native CLI platform integration that provides comprehensive Android development support through command-line tools and utilities. This package delivers three core commands (run-android, build-android, log-android) along with extensive device management, emulator control, and build automation capabilities for React Native Android development workflows.
import {
commands,
adb,
getAdbPath,
listAndroidDevices,
tryRunAdbReverse,
projectConfig,
dependencyConfig,
getAndroidProject,
getPackageName,
isProjectUsingKotlin
} from "@react-native-community/cli-platform-android";For CommonJS:
const {
commands,
adb,
getAdbPath,
listAndroidDevices,
tryRunAdbReverse,
projectConfig,
dependencyConfig
} = require("@react-native-community/cli-platform-android");import { commands, listAndroidDevices } from "@react-native-community/cli-platform-android";
// Access CLI commands for registration with React Native CLI
const androidCommands = commands;
// List available Android devices interactively
const selectedDevice = await listAndroidDevices();
if (selectedDevice) {
console.log(`Selected: ${selectedDevice.readableName}`);
}React Native CLI Platform Android is structured around several key components:
Core Android development commands integrated with React Native CLI, providing build, run, and logging functionality.
interface Command {
name: string;
description?: string;
func: (argv: Array<string>, config: Config, args: any) => Promise<void> | void;
options?: CommandOption[];
}
// Array of three command objects: [logAndroid, runAndroid, buildAndroid]
const commands: Command[];ADB integration for discovering, selecting, and managing Android devices and emulators.
// ADB utilities object
const adb: {
getDevices: (adbPath: string) => Array<string>;
getAvailableCPUs: (adbPath: string, device: string) => Array<string>;
getCPU: (adbPath: string, device: string) => string | null;
};
// Get ADB executable path
function getAdbPath(): string;
// Interactive device selection
function listAndroidDevices(): Promise<DeviceData | undefined>;
// Device information structure
interface DeviceData {
deviceId: string | undefined;
readableName: string;
connected: boolean;
type: 'emulator' | 'phone';
}Network setup utilities for React Native development, including Metro bundler port forwarding.
// Set up reverse port forwarding for Metro bundler
function tryRunAdbReverse(packagerPort: number | string, device?: string | void): void;Configuration utilities for Android project setup and dependency management, re-exported from cli-config-android.
// Android project configuration
function projectConfig(root: string, userConfig?: AndroidProjectParams): AndroidProjectConfig | null;
// Dependency configuration
function dependencyConfig(root: string, userConfig?: AndroidDependencyParams | null): AndroidDependencyConfig | null;
// Get Android project configuration object from Config
function getAndroidProject(config: Config): AndroidProjectConfig;
// Extract package name from Android project files
function getPackageName(manifestPath?: string | null, buildGradlePath?: string | null): string;
// Check if project uses Kotlin
function isProjectUsingKotlin(config: Config): boolean;Build system utilities for Gradle task execution, accessible through buildAndroid command imports in sub-packages.
// Execute Gradle build with specified arguments
function build(gradleArgs: string[], sourceDir: string): void;
// Build command options configuration
const options: CommandOption[];Emulator lifecycle management accessible through device selection and CLI commands. Emulator functions are internal to the command implementations and not directly exported.
This package contains many internal utility functions that support the CLI commands but are not exported from the main module. These include:
These internal functions are documented in the sub-docs for reference but are not directly importable from the package.
// Configuration object for CLI commands (simplified from @react-native-community/cli-types)
interface Config {
root: string;
reactNativePath: string;
reactNativeVersion: string;
project: {
android?: AndroidProjectConfig;
[key: string]: any;
};
[key: string]: any;
}
// Android project configuration (from @react-native-community/cli-types)
interface AndroidProjectConfig {
sourceDir: string;
appName: string;
packageName: string;
applicationId: string;
mainActivity: string;
dependencyConfiguration?: string;
watchModeCommandParams?: string[];
assets: string[];
}
// Android project parameters for configuration
interface AndroidProjectParams {
sourceDir?: string;
appName?: string;
manifestPath?: string;
packageName?: string;
dependencyConfiguration?: string;
watchModeCommandParams?: string[];
assets?: string[];
}
// Android dependency configuration
interface AndroidDependencyConfig {
sourceDir: string;
packageImportPath: string | null;
packageInstance: string | null;
dependencyConfiguration?: string;
buildTypes: string[];
libraryName?: string | null;
componentDescriptors?: string[] | null;
cmakeListsPath?: string | null;
cxxModuleCMakeListsModuleName?: string | null;
cxxModuleCMakeListsPath?: string | null;
cxxModuleHeaderName?: string | null;
isPureCxxDependency?: boolean;
}
// Android dependency parameters
interface AndroidDependencyParams {
sourceDir?: string;
manifestPath?: string;
packageName?: string;
dependencyConfiguration?: string;
packageImportPath?: string;
packageInstance?: string;
buildTypes?: string[];
libraryName?: string | null;
componentDescriptors?: string[] | null;
cmakeListsPath?: string | null;
cxxModuleCMakeListsModuleName?: string | null;
cxxModuleCMakeListsPath?: string | null;
cxxModuleHeaderName?: string | null;
}
// Command option definition
interface CommandOption {
name: string;
description?: string;
parse?: (val: string) => any;
default?: any;
}
// User profile information for multi-user devices
interface User {
id: string;
name: string;
}