CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-react-native-community--cli-platform-android

Android platform commands for React Native CLI providing run-android, build-android, and log-android commands for managing Android development workflow

Pending
Overview
Eval results
Files

commands.mddocs/

CLI Commands

Core Android development commands integrated with React Native CLI, providing comprehensive build, run, and logging functionality for Android development workflows.

Capabilities

run-android Command

Builds and launches React Native apps on Android devices or emulators with comprehensive configuration options.

/**
 * Builds your app and starts it on a connected Android emulator or device
 * @param _argv - Command line arguments array
 * @param config - React Native CLI configuration object
 * @param args - Parsed command options
 */
async function runAndroid(_argv: Array<string>, config: Config, args: RunAndroidFlags): Promise<void>;

interface RunAndroidFlags extends BuildFlags {
  /** Application ID to launch after build */
  appId: string;
  /** Application ID suffix */
  appIdSuffix: string;
  /** Name of the activity to start */
  mainActivity?: string;
  /** Metro Bundler port (default: 8081) */
  port: number;
  /** Terminal path for Metro Bundler */
  terminal?: string;
  /** Do not launch packager while running the app */
  packager?: boolean;
  /** Explicitly set device to use by name */
  device?: string;
  /** DEPRECATED: Device ID (use --device instead) */
  deviceId?: string;
  /** List all available devices and let user choose */
  listDevices?: boolean;
  /** Path to pre-built .apk binary */
  binaryPath?: string;
  /** User Profile ID for app installation */
  user?: number | string;
}

Command Options:

  • --no-packager: Do not launch packager while running the app
  • --port <number>: Metro Bundler port (default: 8081)
  • --terminal <string>: Terminal path for Metro Bundler
  • --appId <string>: Application ID to launch after build
  • --appIdSuffix <string>: Application ID suffix
  • --main-activity <string>: Name of the activity to start
  • --device <string>: Explicitly set device to use by name
  • --deviceId <string>: DEPRECATED Device ID (use --device instead)
  • --list-devices: List all available devices and let user choose
  • --binary-path <string>: Path to pre-built .apk binary
  • --user <number>: User Profile ID for app installation
  • Plus all build-android command options

Usage Examples:

# Run on default device
npx react-native run-android

# Run on specific device
npx react-native run-android --device "Pixel_4_API_30"

# Run with interactive device selection
npx react-native run-android --list-devices

# Run with specific port and no packager
npx react-native run-android --port 8082 --no-packager

# Run pre-built APK
npx react-native run-android --binary-path ./android/app/build/outputs/apk/debug/app-debug.apk

build-android Command

Builds React Native Android apps with various configuration options and Gradle task support.

/**
 * Builds your app
 * @param _argv - Command line arguments array
 * @param config - React Native CLI configuration object
 * @param args - Parsed build options
 */
async function buildAndroid(_argv: Array<string>, config: Config, args: BuildFlags): Promise<void>;

interface BuildFlags {
  /** Specify app's build variant */
  mode?: string;
  /** Build native libraries only for current device architecture for debug builds */
  activeArchOnly?: boolean;
  /** Run custom Gradle tasks (comma-separated) */
  tasks?: Array<string>;
  /** Custom params passed to gradle build command (space-separated) */
  extraParams?: Array<string>;
  /** Explicitly select build type and flavour to use before running a build */
  interactive?: boolean;
}

/**
 * Execute Gradle build with specified arguments
 * @param gradleArgs - Arguments to pass to Gradle
 * @param sourceDir - Android source directory path
 */
function build(gradleArgs: string[], sourceDir: string): void;

Command Options:

  • --mode <string>: Specify app's build variant (debug, release, etc.)
  • --tasks <list>: Run custom Gradle tasks (comma-separated)
  • --active-arch-only: Build native libraries only for current device architecture for debug builds
  • --extra-params <string>: Custom params passed to gradle build command (space-separated)
  • -i --interactive: Explicitly select build type and flavour to use before running a build

Usage Examples:

# Build debug variant
npx react-native build-android

# Build release variant
npx react-native build-android --mode release

# Build with custom tasks
npx react-native build-android --tasks assembleDebug,bundleDebug

# Interactive build selection
npx react-native build-android --interactive

# Build with extra Gradle parameters
npx react-native build-android --extra-params "--stacktrace --info"

log-android Command

Starts Android logging using logkitty for formatted log output.

/**
 * Starts logkitty for Android log viewing
 */
async function logAndroid(): Promise<void>;

Usage Examples:

# Start Android logging
npx react-native log-android

Internal Functions

App Installation and Launch

/**
 * Install APK on specified Android device
 * @param args - Command arguments with installation options
 * @param adbPath - Path to ADB executable
 * @param device - Target device identifier
 * @param androidProject - Android project configuration
 * @param selectedTask - Optional Gradle task name
 */
function tryInstallAppOnDevice(
  args: RunAndroidFlags,
  adbPath: string,
  device: string,
  androidProject: AndroidProject,
  selectedTask?: string,
): void;

/**
 * Launch installed app on Android device
 * @param device - Target device identifier
 * @param androidProject - Android project configuration
 * @param adbPath - Path to ADB executable
 * @param args - Command arguments with launch options
 */
function tryLaunchAppOnDevice(
  device: string | void,
  androidProject: AndroidProject,
  adbPath: string,
  args: RunAndroidFlags,
): void;

/**
 * Execute installation on all connected devices
 * @param args - Command arguments
 * @param cmd - Command to execute
 * @param adbPath - Path to ADB executable
 * @param androidProject - Android project configuration
 */
async function runOnAllDevices(
  args: RunAndroidFlags,
  cmd: string,
  adbPath: string,
  androidProject: AndroidProject,
): Promise<void>;

Task Name Generation

/**
 * Generate Gradle task names for builds
 * @param appName - Application name
 * @param mode - Build mode (debug, release, etc.)
 * @param tasks - Custom task names
 * @param taskPrefix - Task prefix type
 * @returns Array of Gradle task names
 */
function getTaskNames(
  appName: string,
  mode: BuildFlags['mode'] = 'debug',
  tasks: BuildFlags['tasks'],
  taskPrefix: 'assemble' | 'install' | 'bundle',
): Array<string>;

Port Management

/**
 * Find an available port for development server
 * @param port - Preferred port number
 * @returns Promise resolving to available port
 */
function getAvailableDevicePort(port?: number): Promise<number>;

Utility Functions

/**
 * Convert string to PascalCase format
 * @param value - Input string to convert
 * @returns PascalCase formatted string
 */
function toPascalCase(value: string): string;

Install with Tessl CLI

npx tessl i tessl/npm-react-native-community--cli-platform-android

docs

build-system.md

commands.md

device-management.md

emulator-management.md

index.md

network-configuration.md

project-configuration.md

tile.json