0
# Project Configuration
1
2
Android project configuration utilities for React Native CLI, providing project detection, dependency management, and build configuration. These functions are re-exported from `@react-native-community/cli-config-android`.
3
4
## Capabilities
5
6
### Project Configuration
7
8
Core Android project configuration for React Native CLI integration.
9
10
```typescript { .api }
11
/**
12
* Android project configuration function
13
* Returns configuration object for Android project detection and setup
14
* @returns Android project configuration object
15
*/
16
function projectConfig(): any;
17
```
18
19
**Usage Examples:**
20
21
```typescript
22
import { projectConfig } from "@react-native-community/cli-platform-android";
23
24
// Get Android project configuration
25
const config = projectConfig();
26
console.log("Android project config:", config);
27
```
28
29
### Dependency Configuration
30
31
Configuration for Android dependencies and native modules.
32
33
```typescript { .api }
34
/**
35
* Android dependency configuration function
36
* Returns configuration for managing Android dependencies and native modules
37
* @returns Android dependency configuration object
38
*/
39
function dependencyConfig(): any;
40
```
41
42
**Usage Examples:**
43
44
```typescript
45
import { dependencyConfig } from "@react-native-community/cli-platform-android";
46
47
// Get dependency configuration
48
const depConfig = dependencyConfig();
49
console.log("Android dependency config:", depConfig);
50
```
51
52
### Android Project Detection
53
54
Utilities for detecting and retrieving Android project information.
55
56
```typescript { .api }
57
/**
58
* Get Android project configuration object
59
* Detects and returns Android project configuration from the current directory
60
* @returns Android project configuration object or null if not found
61
*/
62
function getAndroidProject(): any;
63
64
/**
65
* Extract Android package name from project
66
* Reads the package name from Android project configuration
67
* @returns Android package name string
68
*/
69
function getPackageName(): string;
70
```
71
72
**Usage Examples:**
73
74
```typescript
75
import { getAndroidProject, getPackageName } from "@react-native-community/cli-platform-android";
76
77
// Get Android project configuration
78
const androidProject = getAndroidProject();
79
if (androidProject) {
80
console.log("Android project found:", androidProject);
81
82
// Get package name
83
const packageName = getPackageName();
84
console.log("Package name:", packageName);
85
}
86
```
87
88
### Language Detection
89
90
Utilities for detecting the programming language used in Android projects.
91
92
```typescript { .api }
93
/**
94
* Check if Android project uses Kotlin
95
* Analyzes project files to determine if Kotlin is being used
96
* @returns true if project uses Kotlin, false if Java
97
*/
98
function isProjectUsingKotlin(): boolean;
99
```
100
101
**Usage Examples:**
102
103
```typescript
104
import { isProjectUsingKotlin } from "@react-native-community/cli-platform-android";
105
106
// Check project language
107
const usesKotlin = isProjectUsingKotlin();
108
if (usesKotlin) {
109
console.log("Project uses Kotlin");
110
} else {
111
console.log("Project uses Java");
112
}
113
```
114
115
## Configuration Integration
116
117
### React Native CLI Integration
118
119
These configuration functions are primarily used internally by React Native CLI for:
120
121
- **Project Discovery**: Automatically detecting Android projects in monorepos or standard React Native projects
122
- **Build Configuration**: Setting up proper build paths and parameters for Gradle builds
123
- **Dependency Management**: Managing native module dependencies and linking
124
- **Platform Detection**: Identifying Android-specific configuration requirements
125
126
### Configuration Object Structure
127
128
While the exact structure depends on the underlying cli-config-android implementation, typical configuration objects include:
129
130
- **Source Directory**: Path to Android source code
131
- **Build Directory**: Path to build outputs
132
- **Application Name**: Android app name
133
- **Package Name**: Android package identifier
134
- **Gradle Configuration**: Build tool settings
135
- **Manifest Location**: AndroidManifest.xml path
136
- **Resources Directory**: Android resources path
137
138
### Usage in Commands
139
140
These configuration functions are automatically used by the CLI commands:
141
142
```typescript
143
// Internal usage in run-android command
144
const androidProject = getAndroidProject();
145
const packageName = getPackageName();
146
const isKotlin = isProjectUsingKotlin();
147
148
// Use configuration for build and run operations
149
if (androidProject) {
150
// Proceed with Android-specific operations
151
}
152
```
153
154
## Important Notes
155
156
- These functions are **re-exported** from `@react-native-community/cli-config-android`
157
- They provide a stable interface for Android project configuration
158
- Return types may vary based on project structure and cli-config-android version
159
- Functions may return `null` or `undefined` if Android project is not detected
160
- Used internally by CLI commands but can be accessed directly for custom tooling