Comprehensive troubleshooting guide for common issues across Android, iOS, and React Native development with Devbox plugins.
Use Ctrl/Cmd+F to search for specific error messages or symptoms.
Common error patterns:
ANDROID_SDK_ROOT not set→ SDK Not FoundXcode developer directory not found→ Xcode Not FoundRuntime iOS X.X not found→ Simulator Runtime MissingEmulator won't start→ Emulator Won't StartCoreSimulatorService connection became invalid→ CoreSimulatorService IssuesMetro port already in use→ Metro Port ConflictsLock file checksum mismatch→ Lock File Out of SyncAPK installation failed→ App Installation Fails
Symptom: devbox shell takes several minutes to start.
Root cause: Android SDK flake evaluation or iOS setup evaluating all devices.
Solutions:
-
Limit devices to evaluate (most effective):
{ "env": { "ANDROID_DEVICES": "min,max", "IOS_DEVICES": "min,max" } } -
Skip unused platforms in React Native:
{ "env": { "ANDROID_SKIP_SETUP": "1", "IOS_SKIP_SETUP": "1" } } -
Regenerate lock files:
devbox run android.sh devices eval devbox run ios.sh devices eval
Prevention: Always commit lock files to version control for fast CI builds.
Symptom: Plugin commands not available or initialization hooks not running.
Root cause: Incorrect plugin path in devbox.json or missing include directive.
Solutions:
-
Verify plugin inclusion in
devbox.json:{ "include": [ "github:segment-integrations/devbox-plugins?dir=plugins/android", "github:segment-integrations/devbox-plugins?dir=plugins/ios" ] } -
Check plugin is loaded:
devbox shell echo $ANDROID_SCRIPTS_DIR echo $IOS_SCRIPTS_DIR
-
Regenerate virtenv:
devbox run devbox_sync
Symptom: Commands fail with "variable not set" errors.
Root cause: Environment not sourced or virtenv stale.
Solutions:
-
Source the environment manually:
. ${ANDROID_RUNTIME_DIR}/scripts/init/setup.sh . ${IOS_RUNTIME_DIR}/scripts/init/setup.sh
-
Regenerate virtenv:
devbox run devbox_sync
-
Verify environment:
devbox run android.sh info devbox run ios.sh info
Symptom: Error message "ANDROID_SDK_ROOT not set" or SDK tools not found.
Root cause: Android environment not initialized or using devbox shell instead of devbox run.
Solutions:
-
Use
devbox runinstead ofdevbox shell:# Correct devbox run android.sh devices list # Incorrect devbox shell android.sh devices list # May not work
-
Source the Android environment in shell:
devbox shell . ${ANDROID_RUNTIME_DIR}/scripts/init/setup.sh
-
Verify SDK installation:
devbox run android.sh info
-
Check
ANDROID_SDK_ROOT:echo $ANDROID_SDK_ROOT ls -la $ANDROID_SDK_ROOT
-
Regenerate the environment:
devbox run devbox_sync
Prevention: Always use devbox run for commands, or source environment in interactive shells.
Symptom: "Xcode developer directory not found" or Xcode tools unavailable.
Root cause: Xcode not installed or xcode-select path incorrect.
Solutions:
-
Check if Xcode is installed:
xcode-select -p
-
Install Xcode from the App Store, then set the active developer directory:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
-
Or install command-line tools only:
xcode-select --install
-
Set explicit path in
devbox.json:{ "env": { "IOS_DEVELOPER_DIR": "/Applications/Xcode.app/Contents/Developer" } } -
Clear Xcode cache and rediscover:
rm -f .devbox/virtenv/ios/.xcode_dev_dir.cache devbox run ios.sh info
Prevention: Install Xcode before using iOS plugin.
Symptom: Gradle build fails with "SDK Build Tools version X not found".
Root cause: build.gradle specifies build tools version not in Nix SDK.
Solutions:
-
Check available build tools:
devbox run android.sh info
-
Update build tools version in
devbox.json:{ "env": { "ANDROID_BUILD_TOOLS_VERSION": "36.1.0" } } -
Sync Gradle configuration with SDK version in
app/build.gradle:android { compileSdk 36 buildToolsVersion "36.1.0" }
-
Regenerate environment:
devbox run devbox_sync
Prevention: Keep devbox.json and build.gradle versions synchronized.
Symptom: "Runtime iOS X.X not found" or simulator won't start due to missing runtime.
Root cause: iOS runtime not installed via Xcode.
Solutions:
-
List available runtimes:
xcrun simctl list runtimes
-
Download runtime via Xcode Settings:
- Open Xcode
- Go to Settings > Platforms
- Click "+" to download iOS Simulator runtimes
-
Enable auto-download in
devbox.json:{ "env": { "IOS_DOWNLOAD_RUNTIME": "1" } } -
Or download via command line:
xcodebuild -downloadPlatform iOS
-
Skip devices with missing runtimes:
devbox run ios.sh devices sync
Prevention: Install iOS runtimes before creating device definitions.
Symptom: Emulator fails to start or times out during boot.
Root cause: Hardware acceleration unavailable, snapshot corruption, or resource constraints.
Solutions:
-
Check if hardware acceleration is available:
devbox run emulator -accel-check
-
Try starting with snapshot disabled:
ANDROID_DISABLE_SNAPSHOTS=1 devbox run start:emu
-
Reset emulator state:
devbox run android.sh emulator reset max
-
Increase boot timeout:
BOOT_TIMEOUT=180 devbox run start:emu
-
Check system resources:
top # or htop -
View emulator logs:
tail -f reports/logs/*.log -
Try headless mode:
EMU_HEADLESS=1 devbox run start:emu
Prevention: Ensure virtualization is enabled in BIOS and sufficient RAM available (4GB+ recommended).
Symptom: "CoreSimulatorService connection became invalid" or simulators won't start.
Root cause: CoreSimulatorService crashed or corrupted state.
Solutions:
-
Restart CoreSimulatorService:
killall -9 CoreSimulatorService
-
Check service status:
launchctl list | grep CoreSimulator -
Kickstart the service:
launchctl kickstart -k gui/$UID/com.apple.CoreSimulatorService -
Open Simulator app to initialize:
open -a Simulator
-
Check simulator device state:
xcrun simctl list devices
-
Delete and recreate simulator:
xcrun simctl delete "Device Name" devbox run ios.sh devices sync
Prevention: Restart CoreSimulatorService periodically if simulators are unstable.
Symptom: iOS simulator times out during boot or fails to start.
Root cause: Resource constraints, disk space, or runtime issues.
Solutions:
-
Increase boot timeout:
BOOT_TIMEOUT=180 devbox run start:sim
-
Check system resources:
top # or htop -
View simulator logs:
tail -f ~/Library/Logs/CoreSimulator/*/system.log
-
Check disk space:
df -h
-
Restart your Mac if simulators are consistently failing.
-
Delete simulator and recreate:
xcrun simctl delete "Device Name" devbox run ios.sh devices sync
Prevention: Ensure sufficient disk space (10GB+ free) and RAM (8GB+ recommended).
Symptom: Multiple Android emulators running on the same port or conflicting.
Root cause: Port collision or improper cleanup.
Solutions:
-
Stop all emulators:
devbox run stop:emu
-
Specify different ports for each emulator:
EMU_PORT=5554 devbox run start:emu device1 EMU_PORT=5556 devbox run start:emu device2
-
Use device serials explicitly:
ANDROID_SERIAL=emulator-5554 devbox run start:app
-
List running emulators:
adb devices
Prevention: Use devbox run --pure for isolated testing or specify unique ports.
Symptom: Gradle build fails with dependency or configuration errors.
Root cause: Gradle cache corruption, version mismatch, or missing dependencies.
Solutions:
-
Clean Gradle build:
cd android && gradle clean devbox run build
-
Clear Gradle cache:
rm -rf ~/.gradle/caches/ rm -rf android/.gradle/ -
Verify environment:
devbox run android.sh info
-
Check Gradle wrapper version:
cd android && ./gradlew --version
-
Update Gradle dependencies:
cd android && ./gradlew --refresh-dependencies
Prevention: Keep Gradle and plugin versions up to date.
Symptom: Xcode build fails with signing, provisioning, or linker errors.
Root cause: Code signing issues, Nix environment conflicts, or stale derived data.
Solutions:
-
Clean derived data:
rm -rf .devbox/virtenv/ios/DerivedData
-
Reinstall CocoaPods:
cd ios && pod install --repo-update
-
Rebuild:
devbox run build
-
Check code signing:
defaults read "$IOS_APP_ARTIFACT/Info.plist" CFBundleIdentifier
-
Use
ios.sh xcodebuildwrapper which strips Nix flags in a subshell:ios.sh xcodebuild -scheme MyApp build
Alternatively,
xcodebuildworks natively in devbox shell since Nix vars are stripped at init time.
Prevention: Use automatic code signing and keep CocoaPods updated.
Symptom: Build errors related to linker flags or Nix environment variables.
Root cause: Nix environment variables interfering with native toolchains.
Solutions:
-
The iOS init hook strips Nix compilation variables (
LD,LDFLAGS,NIX_LDFLAGS,NIX_CFLAGS_COMPILE,NIX_CFLAGS_LINK) at shell startup. Verify they are unset:echo "LD=$LD LDFLAGS=$LDFLAGS"
-
For Android, ensure Gradle uses project JDK:
# In android/gradle.properties org.gradle.java.home=/path/to/jdk
-
Use
devbox run --purefor isolated builds:devbox run --pure build-android devbox run --pure build-ios
Prevention: Plugins handle Nix environment cleanup automatically.
Symptom: Error installing APK on emulator.
Root cause: APK path incorrect, app already installed, or emulator not ready.
Solutions:
-
Verify APK path is correct:
echo $ANDROID_APP_APK ls -l $ANDROID_APP_APK
-
Check if app is already installed:
adb shell pm list packages | grep your.package.name -
Uninstall existing version:
adb uninstall com.example.myapp
-
Check emulator is fully booted:
adb shell getprop sys.boot_completed # Should return "1" -
Wait for emulator boot:
adb wait-for-device
-
Try manual installation:
adb install -r $ANDROID_APP_APK
Prevention: Always wait for emulator to fully boot before installing apps.
Symptom: Error installing app on simulator or app doesn't launch.
Root cause: Bundle path incorrect, simulator not booted, or bundle ID mismatch.
Solutions:
-
Verify app bundle exists:
ls -la $IOS_APP_ARTIFACT -
Check simulator is booted:
xcrun simctl list devices | grep Booted -
Verify bundle ID:
defaults read "$IOS_APP_ARTIFACT/Info.plist" CFBundleIdentifier
-
Check app bundle structure:
ls -la "$IOS_APP_ARTIFACT/" # Should contain: Info.plist, executable, etc.
-
Try manual installation:
xcrun simctl install booted "$IOS_APP_ARTIFACT" -
Launch manually:
xcrun simctl launch booted "$IOS_APP_BUNDLE_ID"
Prevention: Verify bundle ID matches between Xcode project and devbox.json.
Symptom: App installs but crashes on launch.
Root cause: Runtime errors, missing dependencies, or architecture mismatch.
Solutions:
-
View app logs (Android):
adb logcat | grep "$(basename $ANDROID_APP_ID)"
-
View app logs (iOS):
xcrun simctl spawn booted log stream --predicate 'process == "YourApp"' -
Check architecture compatibility (Android):
unzip -l $ANDROID_APP_APK | grep lib/
-
Debug in development mode:
BUILD_CONFIG=Debug devbox run start:app BUILD_CONFIG=Debug devbox run start:ios
-
Check for missing native libraries or frameworks.
Prevention: Test builds in Debug configuration before Release builds.
Symptom: "Metro port already in use" or "EADDRINUSE: address already in use".
Root cause: Metro already running on the port or port not released.
Solutions:
-
Check what's using the port:
lsof -ti:8081 lsof -ti:8091
-
Stop Metro for specific suite:
metro.sh stop android metro.sh stop ios
-
Kill process on port:
lsof -ti:8081 | xargs kill -9
-
Clean all Metro state:
metro.sh clean android metro.sh clean ios rm -rf .devbox/virtenv/react-native/metro/
-
Use dynamic port allocation (default behavior):
# Metro automatically allocates ports 8091-8199 devbox run start:android
Prevention: Always use metro.sh stop to clean up Metro processes.
Symptom: Code changes don't appear in app or hot reload fails.
Root cause: Metro cache stale or connection lost.
Solutions:
-
Check Metro is running:
metro.sh status android
-
Check Metro logs for errors:
tail -f reports/react-native-android-dev-logs/metro-bundler.log
-
Force reload in app:
- Android: Press
Rtwice orCtrl/Cmd + Mto open Dev Menu - iOS: Press
Rin simulator
- Android: Press
-
Restart Metro with cache reset:
metro.sh stop android metro.sh start android --reset-cache
-
Check Metro port configuration:
cat .devbox/virtenv/react-native/metro/port-android.txt cat .devbox/virtenv/react-native/metro/env-android.sh
Prevention: Keep Metro running during development and avoid port conflicts.
Symptom: App shows "Could not connect to development server" or times out connecting to Metro.
Root cause: Metro not started, wrong port, or network configuration.
Solutions:
-
Verify Metro is running:
metro.sh health android android # Exit code 0 = healthy, non-zero = unhealthy -
Check Metro port:
cat .devbox/virtenv/react-native/metro/port-android.txt
-
Test Metro connectivity:
curl http://localhost:$(cat .devbox/virtenv/react-native/metro/port-android.txt)/status -
Restart Metro:
metro.sh stop android metro.sh start android
-
Check app is using correct Metro port (view app logs).
Prevention: Wait for Metro to fully start before launching app.
Symptom: "Warning: devices.lock may be stale" or checksum mismatch.
Root cause: Device definitions changed but lock file not regenerated.
Solutions:
-
Regenerate lock file (Android):
devbox run android.sh devices eval -
Regenerate lock file (iOS):
devbox run ios.sh devices eval -
Commit updated lock file:
git add devbox.d/*/devices/devices.lock git commit -m "chore: update device lock files"
Prevention: Always regenerate lock files after creating, updating, or deleting devices.
Symptom: AVD/simulator doesn't match device definition or uses old configuration.
Root cause: Devices not synced after definition changes.
Solutions:
-
Sync AVDs with definitions (Android):
devbox run android.sh devices sync
-
Sync simulators with definitions (iOS):
devbox run ios.sh devices sync
-
View sync results to see what changed:
- Matched: Already correct
- Recreated: Deleted and recreated
- Created: Newly created
- Skipped: Missing runtime or dependency
-
Regenerate lock file after sync:
devbox run android.sh devices eval devbox run ios.sh devices eval
Prevention: Run sync after pulling device definition changes from version control.
Symptom: Cannot create device or device creation reports errors.
Root cause: Invalid parameters, missing runtime, or system resource limits.
Solutions:
-
Verify parameters are correct (Android):
# Check valid device profiles avdmanager list device # Check valid API levels sdkmanager --list | grep "system-images"
-
Verify runtime available (iOS):
xcrun simctl list runtimes
-
Check device name doesn't conflict:
# Android devbox run android.sh devices list # iOS devbox run ios.sh devices list
-
Ensure sufficient disk space:
df -h
-
View detailed error logs:
ANDROID_DEBUG=1 devbox run android.sh devices create ... IOS_DEBUG=1 devbox run ios.sh devices create ...
Prevention: Verify runtimes are installed before creating device definitions.
Symptom: devbox shell takes multiple minutes to initialize.
Root cause: Evaluating too many devices or slow Nix flake evaluation.
Solutions:
-
Limit devices to evaluate:
{ "env": { "ANDROID_DEVICES": "min,max", "IOS_DEVICES": "min,max" } } -
Skip unused platforms:
{ "env": { "ANDROID_SKIP_SETUP": "1", "IOS_SKIP_SETUP": "1" } } -
Commit lock files for faster CI:
git add devbox.d/*/devices/*.lock* git commit -m "chore: add device lock files"
-
Clear Nix cache if corrupted:
nix-collect-garbage -d
Prevention: Always use lock files and limit device evaluation.
Symptom: Builds take longer than expected.
Root cause: No build cache, large project, or resource constraints.
Solutions:
-
Enable Gradle build cache (Android):
# In android/gradle.properties org.gradle.caching=true org.gradle.parallel=true
-
Use incremental builds:
# Don't clean between builds devbox run build # Subsequent builds are faster
-
Increase Gradle memory (Android):
# In android/gradle.properties org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m
-
Check system resources:
top # Ensure CPU/memory available -
Use Debug builds in development:
BUILD_CONFIG=Debug devbox run build
Prevention: Keep build caches and use incremental builds.
Symptom: Emulator runs slowly or lags.
Root cause: No hardware acceleration, insufficient resources, or snapshot issues.
Solutions:
-
Verify hardware acceleration:
devbox run emulator -accel-check
-
Use headless mode to save resources:
EMU_HEADLESS=1 devbox run start:emu
-
Disable snapshots for better performance:
ANDROID_DISABLE_SNAPSHOTS=1 devbox run start:emu
-
Allocate more RAM to emulator (edit device JSON):
{ "name": "my_device", "ram": "4096" } -
Close other resource-intensive applications.
Prevention: Ensure virtualization enabled in BIOS and sufficient RAM allocated.
Enable verbose logging to diagnose issues:
# Platform-specific debug
ANDROID_DEBUG=1 devbox shell
IOS_DEBUG=1 devbox shell
# Global debug
DEBUG=1 devbox shell
# Debug during tests
ANDROID_DEBUG=1 devbox run test:e2e
IOS_DEBUG=1 devbox run test:e2e
# Combined
DEBUG=1 ANDROID_DEBUG=1 IOS_DEBUG=1 devbox shellDebug logs show:
- Environment variable resolution
- SDK/Xcode path discovery
- Device configuration loading
- Emulator/simulator startup commands
- App deployment steps
- Metro bundler operations
Test logs are written to reports/ directory:
# List all logs
ls -la reports/logs/
ls -la reports/android-e2e-logs/
ls -la reports/ios-e2e-logs/
ls -la reports/react-native-*-logs/
# View specific process log
cat reports/logs/build-app.log
cat reports/logs/emulator.log
cat reports/logs/simulator.log
cat reports/logs/deploy-app.log
cat reports/logs/metro-bundler.logMonitor running processes:
# Android emulator
adb devices
ps aux | grep emulator
# iOS simulator
xcrun simctl list devices | grep Booted
ps aux | grep Simulator
# Metro bundler
lsof -ti:8081
metro.sh status android
metro.sh status ios
# General process monitoring
top
htop # if installedCheck current configuration:
# Android
devbox run android.sh config show
devbox run android.sh info
# iOS
devbox run ios.sh config show
devbox run ios.sh info
# Environment variables
env | grep ANDROID
env | grep IOS
env | grep METRORun diagnostics to check setup:
# iOS diagnostics
devbox run doctor
# Manual checks
which adb
which emulator
which xcodebuild
which xcrunUse --pure flag for isolated, reproducible testing:
# Pure mode ensures clean state
devbox run --pure test:e2e:android
devbox run --pure test:e2e:ios
# Pure mode for manual testing
devbox run --pure start:emu
devbox run --pure start:simPure mode:
- Fresh environment without previous state
- Isolated from system configuration
- Reproducible results
- Automatic cleanup after completion
Standard debugging approach:
-
Enable debug logging:
DEBUG=1 ANDROID_DEBUG=1 devbox run start:app
-
Check environment:
devbox run android.sh info
-
View logs:
tail -f reports/logs/*.log -
Test in isolation:
devbox run --pure start-android
-
Verify configuration:
devbox run android.sh config show
If issues persist after troubleshooting:
-
Check documentation:
-
Review example projects:
examples/android/- Working Android setupexamples/ios/- Working iOS setupexamples/react-native/- Working React Native setup
-
Enable debug logging and collect information:
DEBUG=1 devbox run your-command 2>&1 | tee debug.log
-
Report issues with:
- Error messages and stack traces
- Debug logs
devbox.jsonconfiguration- Platform and version information
- Steps to reproduce
-
Community support:
- GitHub Issues: Report bugs or request features
- Discord: Join the Jetify community
- Devbox Documentation: jetify.com/devbox/docs