Fix Android emulation and runtime errors for both apps
- Add emulator management scripts (start/stop/status) with logging to /tmp - Fix AVD config: enable GPU acceleration, increase RAM to 4096M - Update babel-preset-expo 9.3.2 -> 55.0.8 to fix RN 0.83 private methods support without breaking polyfills - Add Android package name to expo app.json - Fix Flutter startup crash: call WidgetsFlutterBinding.ensureInitialized before accessing platform channels in db init Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Executable
+85
@@ -0,0 +1,85 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Start Android emulator in headless mode with logging
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export ANDROID_HOME="$HOME/Android/Sdk"
|
||||||
|
export ANDROID_SDK_ROOT="$ANDROID_HOME"
|
||||||
|
export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$HOME/flutter/bin:$PATH"
|
||||||
|
|
||||||
|
AVD_NAME="Pixel_7_API_35"
|
||||||
|
EMU_LOG="/tmp/emulator.log"
|
||||||
|
BOOT_LOG="/tmp/emulator-boot.log"
|
||||||
|
|
||||||
|
# Kill any existing emulator
|
||||||
|
if adb devices 2>/dev/null | grep -q "emulator"; then
|
||||||
|
echo "[$(date)] Killing existing emulator..." | tee -a "$BOOT_LOG"
|
||||||
|
adb emu kill 2>/dev/null || true
|
||||||
|
sleep 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Kill any stale emulator processes
|
||||||
|
pkill -f "qemu-system-x86_64" 2>/dev/null || true
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# Clear old logs
|
||||||
|
> "$EMU_LOG"
|
||||||
|
> "$BOOT_LOG"
|
||||||
|
|
||||||
|
echo "[$(date)] Starting emulator: $AVD_NAME" | tee -a "$BOOT_LOG"
|
||||||
|
echo "[$(date)] Emulator log: $EMU_LOG" | tee -a "$BOOT_LOG"
|
||||||
|
echo "[$(date)] Boot log: $BOOT_LOG" | tee -a "$BOOT_LOG"
|
||||||
|
|
||||||
|
# Start emulator in background with:
|
||||||
|
# - KVM hardware acceleration (auto-detected)
|
||||||
|
# - swiftshader for GPU (headless-compatible)
|
||||||
|
# - no audio/window for CI/headless use
|
||||||
|
# - no snapshot for clean boot
|
||||||
|
nohup emulator -avd "$AVD_NAME" \
|
||||||
|
-no-audio \
|
||||||
|
-no-window \
|
||||||
|
-gpu swiftshader_indirect \
|
||||||
|
-no-snapshot-save \
|
||||||
|
-no-metrics \
|
||||||
|
-wipe-data \
|
||||||
|
> "$EMU_LOG" 2>&1 &
|
||||||
|
|
||||||
|
EMU_PID=$!
|
||||||
|
echo "[$(date)] Emulator PID: $EMU_PID" | tee -a "$BOOT_LOG"
|
||||||
|
|
||||||
|
# Wait for boot to complete (timeout 120s)
|
||||||
|
echo "[$(date)] Waiting for device to come online..." | tee -a "$BOOT_LOG"
|
||||||
|
TIMEOUT=120
|
||||||
|
ELAPSED=0
|
||||||
|
|
||||||
|
# First wait for adb to see the device
|
||||||
|
while ! adb devices 2>/dev/null | grep -q "emulator"; do
|
||||||
|
if [ $ELAPSED -ge $TIMEOUT ]; then
|
||||||
|
echo "[$(date)] TIMEOUT: Device never appeared in adb" | tee -a "$BOOT_LOG"
|
||||||
|
echo "[$(date)] Last emulator log lines:" | tee -a "$BOOT_LOG"
|
||||||
|
tail -20 "$EMU_LOG" | tee -a "$BOOT_LOG"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
ELAPSED=$((ELAPSED + 2))
|
||||||
|
echo "[$(date)] Waiting for adb device... (${ELAPSED}s)" >> "$BOOT_LOG"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[$(date)] Device visible in adb, waiting for boot completion..." | tee -a "$BOOT_LOG"
|
||||||
|
|
||||||
|
# Now wait for boot_completed
|
||||||
|
while [ "$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" != "1" ]; do
|
||||||
|
if [ $ELAPSED -ge $TIMEOUT ]; then
|
||||||
|
echo "[$(date)] TIMEOUT: Boot did not complete within ${TIMEOUT}s" | tee -a "$BOOT_LOG"
|
||||||
|
echo "[$(date)] Boot animation state: $(adb shell getprop init.svc.bootanim 2>/dev/null)" | tee -a "$BOOT_LOG"
|
||||||
|
echo "[$(date)] Last emulator log lines:" | tee -a "$BOOT_LOG"
|
||||||
|
tail -20 "$EMU_LOG" | tee -a "$BOOT_LOG"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
ELAPSED=$((ELAPSED + 2))
|
||||||
|
echo "[$(date)] Waiting for boot... (${ELAPSED}s)" >> "$BOOT_LOG"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[$(date)] Emulator booted successfully in ${ELAPSED}s!" | tee -a "$BOOT_LOG"
|
||||||
|
echo "[$(date)] Device: $(adb devices | grep emulator)" | tee -a "$BOOT_LOG"
|
||||||
|
adb shell getprop ro.build.version.sdk 2>/dev/null | xargs -I{} echo "[$(date)] API level: {}" | tee -a "$BOOT_LOG"
|
||||||
Executable
+29
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Check Android emulator status
|
||||||
|
export ANDROID_HOME="$HOME/Android/Sdk"
|
||||||
|
export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH"
|
||||||
|
|
||||||
|
echo "=== ADB Devices ==="
|
||||||
|
adb devices 2>/dev/null || echo "adb not running"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Emulator Processes ==="
|
||||||
|
ps aux | grep -E "(qemu-system|emulator)" | grep -v grep || echo "No emulator running"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Boot Status ==="
|
||||||
|
if adb devices 2>/dev/null | grep -q "emulator"; then
|
||||||
|
echo "boot_completed: $(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')"
|
||||||
|
echo "boot_anim: $(adb shell getprop init.svc.bootanim 2>/dev/null | tr -d '\r')"
|
||||||
|
echo "API level: $(adb shell getprop ro.build.version.sdk 2>/dev/null | tr -d '\r')"
|
||||||
|
else
|
||||||
|
echo "No emulator connected"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Recent Boot Log ==="
|
||||||
|
tail -10 /tmp/emulator-boot.log 2>/dev/null || echo "No boot log"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Recent Emulator Log (last 10 lines) ==="
|
||||||
|
tail -10 /tmp/emulator.log 2>/dev/null || echo "No emulator log"
|
||||||
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Stop Android emulator cleanly
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export ANDROID_HOME="$HOME/Android/Sdk"
|
||||||
|
export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH"
|
||||||
|
|
||||||
|
BOOT_LOG="/tmp/emulator-boot.log"
|
||||||
|
|
||||||
|
echo "[$(date)] Stopping emulator..." | tee -a "$BOOT_LOG"
|
||||||
|
|
||||||
|
if adb devices 2>/dev/null | grep -q "emulator"; then
|
||||||
|
adb emu kill 2>/dev/null || true
|
||||||
|
sleep 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
pkill -f "qemu-system-x86_64" 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "[$(date)] Emulator stopped." | tee -a "$BOOT_LOG"
|
||||||
+4
-1
@@ -27,6 +27,9 @@
|
|||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"expo-sqlite"
|
"expo-sqlite"
|
||||||
]
|
],
|
||||||
|
"android": {
|
||||||
|
"package": "com.anonymous.todoexpo"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+422
-379
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,7 @@
|
|||||||
"@expo/vector-icons": "^15.0.2",
|
"@expo/vector-icons": "^15.0.2",
|
||||||
"@react-navigation/native": "^6.1.6",
|
"@react-navigation/native": "^6.1.6",
|
||||||
"@react-navigation/native-stack": "^6.9.12",
|
"@react-navigation/native-stack": "^6.9.12",
|
||||||
|
"babel-preset-expo": "^55.0.8",
|
||||||
"create-react-class": "^15.7.0",
|
"create-react-class": "^15.7.0",
|
||||||
"expo": "^55.0.2",
|
"expo": "^55.0.2",
|
||||||
"expo-cli": "^6.3.8",
|
"expo-cli": "^6.3.8",
|
||||||
@@ -30,6 +31,9 @@
|
|||||||
"react-native-web": "^0.21.0"
|
"react-native-web": "^0.21.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/plugin-transform-class-properties": "^7.28.6",
|
||||||
|
"@babel/plugin-transform-private-methods": "^7.28.6",
|
||||||
|
"@babel/plugin-transform-private-property-in-object": "^7.28.6",
|
||||||
"shadow-cljs": "^2.23.3"
|
"shadow-cljs": "^2.23.3"
|
||||||
},
|
},
|
||||||
"private": true
|
"private": true
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
.child (m/Icon m/Icons.add)))))
|
.child (m/Icon m/Icons.add)))))
|
||||||
|
|
||||||
(defn main []
|
(defn main []
|
||||||
|
(m/WidgetsFlutterBinding.ensureInitialized)
|
||||||
(await (db/init-db!))
|
(await (db/init-db!))
|
||||||
(let [todos (await (db/load-todos!))]
|
(let [todos (await (db/load-todos!))]
|
||||||
(when todos
|
(when todos
|
||||||
|
|||||||
Reference in New Issue
Block a user