or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

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

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@react-native-community/cli-platform-android@20.0.x

To install, run

npx @tessl/cli install tessl/npm-react-native-community--cli-platform-android@20.0.0

0

# React Native CLI Platform Android

1

2

React 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.

3

4

## Package Information

5

6

- **Package Name**: @react-native-community/cli-platform-android

7

- **Package Type**: npm

8

- **Language**: TypeScript

9

- **Installation**: Typically installed as part of React Native CLI setup

10

- **Repository**: https://github.com/react-native-community/cli

11

12

## Core Imports

13

14

```typescript

15

import {

16

commands,

17

adb,

18

getAdbPath,

19

listAndroidDevices,

20

tryRunAdbReverse,

21

projectConfig,

22

dependencyConfig,

23

getAndroidProject,

24

getPackageName,

25

isProjectUsingKotlin

26

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

27

```

28

29

For CommonJS:

30

31

```javascript

32

const {

33

commands,

34

adb,

35

getAdbPath,

36

listAndroidDevices,

37

tryRunAdbReverse,

38

projectConfig,

39

dependencyConfig

40

} = require("@react-native-community/cli-platform-android");

41

```

42

43

## Basic Usage

44

45

```typescript

46

import { commands, listAndroidDevices } from "@react-native-community/cli-platform-android";

47

48

// Access CLI commands for registration with React Native CLI

49

const androidCommands = commands;

50

51

// List available Android devices interactively

52

const selectedDevice = await listAndroidDevices();

53

if (selectedDevice) {

54

console.log(`Selected: ${selectedDevice.readableName}`);

55

}

56

```

57

58

## Architecture

59

60

React Native CLI Platform Android is structured around several key components:

61

62

- **CLI Commands**: Three main commands integrated with React Native CLI (run-android, build-android, log-android)

63

- **Device Management**: ADB integration for device discovery, selection, and communication

64

- **Emulator Control**: Automated emulator launching and management

65

- **Build Integration**: Gradle task management and build automation

66

- **Configuration System**: Android project configuration and dependency management

67

- **User Interface**: Interactive prompts for device/emulator selection and build options

68

69

## Capabilities

70

71

### CLI Commands

72

73

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

74

75

```typescript { .api }

76

interface Command {

77

name: string;

78

description?: string;

79

func: (argv: Array<string>, config: Config, args: any) => Promise<void> | void;

80

options?: CommandOption[];

81

}

82

83

// Array of three command objects: [logAndroid, runAndroid, buildAndroid]

84

const commands: Command[];

85

```

86

87

[CLI Commands](./commands.md)

88

89

### Device Management

90

91

ADB integration for discovering, selecting, and managing Android devices and emulators.

92

93

```typescript { .api }

94

// ADB utilities object

95

const adb: {

96

getDevices: (adbPath: string) => Array<string>;

97

getAvailableCPUs: (adbPath: string, device: string) => Array<string>;

98

getCPU: (adbPath: string, device: string) => string | null;

99

};

100

101

// Get ADB executable path

102

function getAdbPath(): string;

103

104

// Interactive device selection

105

function listAndroidDevices(): Promise<DeviceData | undefined>;

106

107

// Device information structure

108

interface DeviceData {

109

deviceId: string | undefined;

110

readableName: string;

111

connected: boolean;

112

type: 'emulator' | 'phone';

113

}

114

```

115

116

[Device Management](./device-management.md)

117

118

### Network Configuration

119

120

Network setup utilities for React Native development, including Metro bundler port forwarding.

121

122

```typescript { .api }

123

// Set up reverse port forwarding for Metro bundler

124

function tryRunAdbReverse(packagerPort: number | string, device?: string | void): void;

125

```

126

127

[Network Configuration](./network-configuration.md)

128

129

### Android Project Configuration

130

131

Configuration utilities for Android project setup and dependency management, re-exported from cli-config-android.

132

133

```typescript { .api }

134

// Android project configuration

135

function projectConfig(root: string, userConfig?: AndroidProjectParams): AndroidProjectConfig | null;

136

137

// Dependency configuration

138

function dependencyConfig(root: string, userConfig?: AndroidDependencyParams | null): AndroidDependencyConfig | null;

139

140

// Get Android project configuration object from Config

141

function getAndroidProject(config: Config): AndroidProjectConfig;

142

143

// Extract package name from Android project files

144

function getPackageName(manifestPath?: string | null, buildGradlePath?: string | null): string;

145

146

// Check if project uses Kotlin

147

function isProjectUsingKotlin(config: Config): boolean;

148

```

149

150

[Project Configuration](./project-configuration.md)

151

152

### Build and Gradle Integration

153

154

Build system utilities for Gradle task execution, accessible through buildAndroid command imports in sub-packages.

155

156

```typescript { .api }

157

// Execute Gradle build with specified arguments

158

function build(gradleArgs: string[], sourceDir: string): void;

159

160

// Build command options configuration

161

const options: CommandOption[];

162

```

163

164

[Build System](./build-system.md)

165

166

### Emulator Management

167

168

Emulator lifecycle management accessible through device selection and CLI commands. Emulator functions are internal to the command implementations and not directly exported.

169

170

[Emulator Management](./emulator-management.md)

171

172

## Internal Functions

173

174

This package contains many internal utility functions that support the CLI commands but are not exported from the main module. These include:

175

176

- Build system utilities (Gradle task management, build execution)

177

- Emulator management functions (launching, discovery)

178

- Device installation and app launching helpers

179

- Port management and network configuration helpers

180

181

These internal functions are documented in the sub-docs for reference but are not directly importable from the package.

182

183

## Types

184

185

```typescript { .api }

186

// Configuration object for CLI commands (simplified from @react-native-community/cli-types)

187

interface Config {

188

root: string;

189

reactNativePath: string;

190

reactNativeVersion: string;

191

project: {

192

android?: AndroidProjectConfig;

193

[key: string]: any;

194

};

195

[key: string]: any;

196

}

197

198

// Android project configuration (from @react-native-community/cli-types)

199

interface AndroidProjectConfig {

200

sourceDir: string;

201

appName: string;

202

packageName: string;

203

applicationId: string;

204

mainActivity: string;

205

dependencyConfiguration?: string;

206

watchModeCommandParams?: string[];

207

assets: string[];

208

}

209

210

// Android project parameters for configuration

211

interface AndroidProjectParams {

212

sourceDir?: string;

213

appName?: string;

214

manifestPath?: string;

215

packageName?: string;

216

dependencyConfiguration?: string;

217

watchModeCommandParams?: string[];

218

assets?: string[];

219

}

220

221

// Android dependency configuration

222

interface AndroidDependencyConfig {

223

sourceDir: string;

224

packageImportPath: string | null;

225

packageInstance: string | null;

226

dependencyConfiguration?: string;

227

buildTypes: string[];

228

libraryName?: string | null;

229

componentDescriptors?: string[] | null;

230

cmakeListsPath?: string | null;

231

cxxModuleCMakeListsModuleName?: string | null;

232

cxxModuleCMakeListsPath?: string | null;

233

cxxModuleHeaderName?: string | null;

234

isPureCxxDependency?: boolean;

235

}

236

237

// Android dependency parameters

238

interface AndroidDependencyParams {

239

sourceDir?: string;

240

manifestPath?: string;

241

packageName?: string;

242

dependencyConfiguration?: string;

243

packageImportPath?: string;

244

packageInstance?: string;

245

buildTypes?: string[];

246

libraryName?: string | null;

247

componentDescriptors?: string[] | null;

248

cmakeListsPath?: string | null;

249

cxxModuleCMakeListsModuleName?: string | null;

250

cxxModuleCMakeListsPath?: string | null;

251

cxxModuleHeaderName?: string | null;

252

}

253

254

// Command option definition

255

interface CommandOption {

256

name: string;

257

description?: string;

258

parse?: (val: string) => any;

259

default?: any;

260

}

261

262

// User profile information for multi-user devices

263

interface User {

264

id: string;

265

name: string;

266

}

267

```