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

network-configuration.mddocs/

Network Configuration

Network setup utilities for React Native development, including Metro bundler port forwarding and reverse proxy configuration for device connectivity.

Capabilities

ADB Reverse Port Forwarding

Sets up reverse port forwarding to allow Android devices to connect to the Metro development server running on the development machine.

/**
 * Set up reverse port forwarding for Metro bundler
 * Runs 'adb reverse tcp:8081 tcp:8081' to allow loading the JS bundle from the packager
 * @param packagerPort - Port number where Metro bundler is running
 * @param device - Optional specific device identifier for reverse forwarding
 */
function tryRunAdbReverse(packagerPort: number | string, device?: string | void): void;

Usage Examples:

import { tryRunAdbReverse } from "@react-native-community/cli-platform-android";

// Set up reverse forwarding for default Metro port
tryRunAdbReverse(8081);

// Set up reverse forwarding for custom port
tryRunAdbReverse(8082);

// Set up reverse forwarding for specific device
tryRunAdbReverse(8081, "emulator-5554");

// Use string port number
tryRunAdbReverse("8081");

Network Configuration Details

Port Forwarding Mechanism

The tryRunAdbReverse function establishes a reverse TCP connection that allows Android devices and emulators to access the Metro development server running on the host machine. This is essential for React Native development as it enables:

  • Hot Reloading: Live updates during development
  • Remote Debugging: DevTools integration
  • Bundle Loading: JavaScript bundle serving from Metro
  • WebSocket Connection: Real-time communication between device and Metro

Default Port Configuration

By default, React Native's Metro bundler runs on port 8081. The reverse port forwarding maps:

  • Device port 8081 → Host port 8081

This allows React Native apps running on Android devices to access http://localhost:8081 and reach the Metro server on the development machine.

Error Handling

The function includes built-in error handling for common scenarios:

  • ADB not found: Gracefully handles missing ADB installation
  • Device not connected: Handles disconnected or unavailable devices
  • Port already in use: Manages port conflicts
  • Permission issues: Handles ADB permission problems

Important Notes:

  • This function is automatically called by the run-android command
  • Manual invocation is useful for custom development setups
  • The reverse forwarding persists until the device is disconnected or ADB server restarts
  • Multiple devices can have reverse forwarding configured simultaneously

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