Skip to content

Commit f9aee15

Browse files
committed
doc updates & app id detection
1 parent a1bb642 commit f9aee15

32 files changed

Lines changed: 583 additions & 268 deletions

File tree

README.md

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,39 @@ Reproducible, project-local development environments for Android, iOS, and React
55
## Quick Start
66

77
```bash
8-
# Add Android plugin to your project
9-
echo '{
10-
"include": ["github:segment-integrations/devbox-plugins?dir=plugins/android"]
11-
}' > devbox.json
8+
# Initialize devbox in your project
9+
devbox init
10+
11+
# Add the Android plugin include to your devbox.json
12+
# (devbox add only works for packages, not plugins — edit devbox.json manually)
13+
```
1214

15+
Add the plugin to your `devbox.json`:
16+
17+
```json
18+
{
19+
"include": ["github:segment-integrations/devbox-plugins?dir=plugins/android"],
20+
"packages": {
21+
"jdk17": "latest",
22+
"gradle": "latest"
23+
},
24+
"env": {
25+
"ANDROID_APP_APK": "app/build/outputs/apk/debug/app-debug.apk"
26+
}
27+
}
28+
```
29+
30+
```bash
1331
# Enter development environment
1432
devbox shell
1533

1634
# Start emulator and run app
17-
devbox run start-emu
18-
devbox run start-app
35+
devbox run start:emu
36+
devbox run start
1937
```
2038

39+
The app's package name is auto-detected from the APK at install time.
40+
2141
**New to devbox-plugins?** Check out the [Quick Start Guide](wiki/guides/quick-start.md) for detailed setup instructions.
2242

2343
## Features
@@ -103,14 +123,14 @@ Each example includes device definitions, test suites, and build scripts.
103123

104124
```bash
105125
# Android
106-
devbox run start-emu # Start Android emulator
107-
devbox run start-app # Build and launch app
108-
devbox run stop-emu # Stop emulator
126+
devbox run start:emu # Start Android emulator
127+
devbox run start # Build, install, and launch app
128+
devbox run stop:emu # Stop emulator
109129

110130
# iOS
111-
devbox run start-sim # Start iOS simulator
112-
devbox run start-ios # Build and launch app
113-
devbox run stop-sim # Stop simulator
131+
devbox run start:sim # Start iOS simulator
132+
devbox run start:ios # Build and launch app
133+
devbox run stop:sim # Stop simulator
114134

115135
# Device management
116136
devbox run android.sh devices list

devbox.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
"test:plugin:android:devices": [
103103
"bash plugins/tests/android/test-devices.sh"
104104
],
105+
"test:plugin:android:apk-detection": [
106+
"(cd examples/android && devbox run bash ../../plugins/tests/android/test-apk-detection.sh)"
107+
],
105108
"test:plugin:android:emulator-detection": [
106109
"(cd examples/android && devbox run bash ../../plugins/tests/android/test-emulator-detection.sh)"
107110
],
@@ -110,7 +113,8 @@
110113
],
111114
"test:plugin:android": [
112115
"devbox run test:plugin:android:lib",
113-
"devbox run test:plugin:android:devices"
116+
"devbox run test:plugin:android:devices",
117+
"devbox run test:plugin:android:apk-detection"
114118
],
115119
"test:plugin:android:all": [
116120
"echo 'Running all Android plugin tests (including emulator tests)...'",

examples/android/devbox.d/android/devices/devices.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
}
1515
],
1616
"checksum": "8df4d3393b61fbbb08e45cf8762f95c521316938e514527916e4fce88a849d57",
17-
"generated_at": "2026-02-18T16:48:27Z"
17+
"generated_at": "2026-02-18T17:45:12Z"
1818
}

examples/android/devbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"stop:emu": [
2121
"android.sh emulator stop"
2222
],
23-
"run": [
23+
"start": [
2424
"android.sh run ${1:-${ANDROID_DEFAULT_DEVICE:-max}}"
2525
],
2626
"test": [

examples/android/tests/test-suite.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,19 @@ processes:
123123
android.sh run ${ANDROID_APP_APK:-app/build/outputs/apk/debug/app-debug.apk}
124124
125125
echo ""
126-
echo "Waiting for app to start..."
126+
# Resolve app ID: env var > auto-detected from APK > fail
127+
app_id="${ANDROID_APP_ID:-$(cat ${ANDROID_RUNTIME_DIR}/app-id.txt 2>/dev/null || true)}"
128+
if [ -z "$app_id" ]; then
129+
echo "ERROR: Cannot determine app ID. Set ANDROID_APP_ID or run deploy first." >&2
130+
exit 1
131+
fi
132+
133+
echo "Waiting for app to start ($app_id)..."
127134
max_attempts=10
128135
attempt=0
129136
while [ $attempt -lt $max_attempts ]; do
130-
if adb -s $serial shell pidof ${ANDROID_APP_ID:-com.example.devbox} >/dev/null 2>&1; then
131-
echo "✓ App process running (PID: $(adb -s $serial shell pidof ${ANDROID_APP_ID:-com.example.devbox}))"
137+
if adb -s $serial shell pidof "$app_id" >/dev/null 2>&1; then
138+
echo "✓ App process running (PID: $(adb -s $serial shell pidof "$app_id"))"
132139
exit 0
133140
fi
134141
attempt=$((attempt + 1))
@@ -161,7 +168,8 @@ processes:
161168
# In pure mode (CI), stop app and emulator for reproducibility
162169
if [ "${IN_NIX_SHELL:-}" = "pure" ]; then
163170
echo "🧹 Cleaning up (pure mode): stopping app and emulator..."
164-
adb -s $serial shell am force-stop ${ANDROID_APP_ID:-com.example.devbox} 2>/dev/null || true
171+
app_id="${ANDROID_APP_ID:-$(cat ${ANDROID_RUNTIME_DIR}/app-id.txt 2>/dev/null || true)}"
172+
[ -n "$app_id" ] && adb -s $serial shell am force-stop "$app_id" 2>/dev/null || true
165173
android.sh emulator stop || true
166174
echo "✓ App stopped, emulator stopped"
167175
else

examples/react-native/devbox.d/android/devices/devices.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
}
1515
],
1616
"checksum": "f5bfab3fdcbe8a23858954c18b1fa86d28a3316e801523aa6d4aa72ca9cf5ab7",
17-
"generated_at": "2026-02-18T17:12:39Z"
17+
"generated_at": "2026-02-18T17:21:12Z"
1818
}

examples/react-native/devbox.d/ios/devices/devices.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
}
1111
],
1212
"checksum": "4d5276f203d7ad62860bfc067f76194df53be449d4aa8a3b2d069855ec1f3232",
13-
"generated_at": "2026-02-18T17:12:40Z"
13+
"generated_at": "2026-02-18T17:21:13Z"
1414
}

examples/react-native/tests/test-suite-all-e2e.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,19 @@ processes:
266266
. ${ANDROID_RUNTIME_DIR}/scripts/init/setup.sh
267267
serial=$(cat ${ANDROID_RUNTIME_DIR}/emulator-serial.txt 2>/dev/null || echo emulator-5554)
268268
269-
echo "Waiting for app to start..."
269+
# Resolve app ID: env var > auto-detected from APK > fail
270+
app_id="${ANDROID_APP_ID:-$(cat ${ANDROID_RUNTIME_DIR}/app-id.txt 2>/dev/null || true)}"
271+
if [ -z "$app_id" ]; then
272+
echo "ERROR: Cannot determine app ID. Set ANDROID_APP_ID or run deploy first." >&2
273+
exit 1
274+
fi
275+
276+
echo "Waiting for app to start ($app_id)..."
270277
max_attempts=10
271278
attempt=0
272279
while [ $attempt -lt $max_attempts ]; do
273-
if adb -s $serial shell pidof ${ANDROID_APP_ID:-com.reactnativeexample} >/dev/null 2>&1; then
274-
echo "✓ App process running (PID: $(adb -s $serial shell pidof ${ANDROID_APP_ID:-com.reactnativeexample}))"
280+
if adb -s $serial shell pidof "$app_id" >/dev/null 2>&1; then
281+
echo "✓ App process running (PID: $(adb -s $serial shell pidof "$app_id"))"
275282
exit 0
276283
fi
277284
attempt=$((attempt + 1))
@@ -333,7 +340,8 @@ processes:
333340
# Cleanup Android
334341
. ${ANDROID_RUNTIME_DIR}/scripts/init/setup.sh
335342
serial=$(cat ${ANDROID_RUNTIME_DIR}/emulator-serial.txt 2>/dev/null || echo emulator-5554)
336-
adb -s $serial shell am force-stop ${ANDROID_APP_ID:-com.reactnativeexample} 2>/dev/null || true
343+
app_id="${ANDROID_APP_ID:-$(cat ${ANDROID_RUNTIME_DIR}/app-id.txt 2>/dev/null || true)}"
344+
[ -n "$app_id" ] && adb -s $serial shell am force-stop "$app_id" 2>/dev/null || true
337345
android.sh emulator stop || true
338346
339347
# Cleanup iOS

examples/react-native/tests/test-suite-android-e2e.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,19 @@ processes:
173173
. ${ANDROID_RUNTIME_DIR}/scripts/init/setup.sh
174174
serial=$(cat ${ANDROID_RUNTIME_DIR}/emulator-serial.txt 2>/dev/null || echo emulator-5554)
175175
176-
echo "Waiting for app to start..."
176+
# Resolve app ID: env var > auto-detected from APK > fail
177+
app_id="${ANDROID_APP_ID:-$(cat ${ANDROID_RUNTIME_DIR}/app-id.txt 2>/dev/null || true)}"
178+
if [ -z "$app_id" ]; then
179+
echo "ERROR: Cannot determine app ID. Set ANDROID_APP_ID or run deploy first." >&2
180+
exit 1
181+
fi
182+
183+
echo "Waiting for app to start ($app_id)..."
177184
max_attempts=10
178185
attempt=0
179186
while [ $attempt -lt $max_attempts ]; do
180-
if adb -s $serial shell pidof ${ANDROID_APP_ID:-com.reactnativeexample} >/dev/null 2>&1; then
181-
echo "✓ App process running (PID: $(adb -s $serial shell pidof ${ANDROID_APP_ID:-com.reactnativeexample}))"
187+
if adb -s $serial shell pidof "$app_id" >/dev/null 2>&1; then
188+
echo "✓ App process running (PID: $(adb -s $serial shell pidof "$app_id"))"
182189
exit 0
183190
fi
184191
attempt=$((attempt + 1))
@@ -210,7 +217,8 @@ processes:
210217
211218
if [ "${IN_NIX_SHELL:-}" = "pure" ]; then
212219
echo "🧹 Cleaning up (pure mode)..."
213-
adb -s $serial shell am force-stop ${ANDROID_APP_ID:-com.reactnativeexample} 2>/dev/null || true
220+
app_id="${ANDROID_APP_ID:-$(cat ${ANDROID_RUNTIME_DIR}/app-id.txt 2>/dev/null || true)}"
221+
[ -n "$app_id" ] && adb -s $serial shell am force-stop "$app_id" 2>/dev/null || true
214222
android.sh emulator stop || true
215223
echo "✓ App stopped, emulator stopped"
216224
else

plugins/android/REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Configure the plugin by setting environment variables in `plugin.json`. These ar
6161

6262
### Run app
6363

64-
- `devbox run run [apk_path] [device]`
64+
- `devbox run start [apk_path] [device]`
6565
- Builds, installs, and launches the app on the emulator
6666
- If `apk_path` is provided, skips build step and installs provided APK
6767
- If no arguments, builds project and installs APK matched by `ANDROID_APP_APK`

0 commit comments

Comments
 (0)