--- name: mobile-android-verification description: Run and verify apps/mobile on a local Android emulator against this worktree's API and relay, with adb and Maestro for input. Use when asked to run, screenshot, verify, or reproduce a mobile change on Android. For iOS use mobile-sim-verification; with no local toolchain (a cloud sandbox) use mobile-eas-dev, which is iOS only. --- # Mobile Android Verification The Android counterpart to `mobile-sim-verification`. Its Rules apply here unchanged: use the real screen, drive state through real services, run the edge pass, never show "unknown" as a negative, record flashes, attribute failures correctly. This file is the Android mechanics. `apps/mobile/scripts/android-dev.sh` does the setup. Read its header for the flags. ## Setup ```bash apps/mobile/scripts/android-dev.sh --doctor # what is missing on this machine apps/mobile/scripts/android-dev.sh # boot, build if needed, Metro, open the app apps/mobile/scripts/android-dev.sh --user maya@local.test # also sign in as a dev account ``` - **Toolchain.** Android Studio's SDK (`~/Library/Android/sdk`) with an AVD, and JDK 17. Gradle for RN 0.88 fails on the Java 8 that macOS often has on `PATH`; `brew install openjdk@17`. The script finds both without `ANDROID_HOME` or `JAVA_HOME` set. For Google sign-in, the AVD needs a Google Play system image and a Google account added on the device. - **Services.** Start the API, relay and realtime as in `mobile-sim-verification` (each in a Paradev terminal). The script reverses Metro, `API_PORT`, `RELAY_PORT`, `REALTIME_PORT` and `WEB_PORT` with `adb reverse`, so `localhost` in the app reaches this machine. A port it does not reverse fails in the app as a network error. - **Build.** `android/` is generated by `expo prebuild` and gitignored. The first Gradle build takes about 10 minutes; later ones reuse the daemon. The script builds only for the emulator's ABI. JS/TS changes need no rebuild: `android-dev.sh --reload`. ## One emulator, many worktrees Every worktree installs the same package, `com.paradev.mobile`, so the last install wins. - The script writes the worktree path and native fingerprint of the installed APK to `/data/local/tmp/superset-mobile-owner` on the device. A mismatch rebuilds, so another worktree's APK is never tested by mistake. Check it before you report: `adb shell cat /data/local/tmp/superset-mobile-owner`. - Agents in parallel workspaces take turns. Ask with `superset agents` before you install or launch, and say when you hand it back. Do not boot a second emulator next to a Gradle build: the machine runs out of memory. - Each worktree's Metro gets its own port (saved in `.tmp/android-dev/metro.port`). Stop it with `--stop` when you are done. ## Traps - **Stale Metro cache.** The transform cache is shared across worktrees. A stale entry fails the Android bundle with a 500: ENOENT on `react-native-worklets/.worklets/.js`. The script starts Metro with `--clear`; if you start Metro yourself, do the same. - **Dev auto sign-in.** `EXPO_PUBLIC_DEV_ONE_TIME_TOKEN` in `.env` signs the app in at launch even after `pm clear`. Blank it and restart Metro to see the sign-in screen. - **Notification permission.** Home asks for `POST_NOTIFICATIONS` once, when the first agent card would show, and remembers the answer. The script grants it up front; to see the prompt, run `adb shell pm revoke com.paradev.mobile android.permission.POST_NOTIFICATIONS` and `pm clear`. - **iOS-only header items.** SF Symbol `Stack.Toolbar` buttons and `Stack.SearchBar` do not render on Android, and a form sheet draws no native bar there (see the sheet convention in `apps/mobile/AGENTS.md`). An empty header on Android is not always a regression. - **The iOS fingerprint.** `app.config.ts`, `eas.json`, `apps/mobile/.gitignore` and `packages/shared/src/app-identity.ts` feed the iOS runtime version even for Android-only edits. Changing them rebuilds and resubmits iOS on merge. Check with `MOBILE_EAS_BUILD=1 node_modules/.bin/fingerprint fingerprint:generate . --platform ios` in `apps/mobile`, and keep such a change in its own commit. - **The Mobile pane** in the desktop app shows the same emulator (local hub, scrcpy stream). It releases an emulator it booted 60 s after its pane closes, which ends an `adb` session on it. If you booted the emulator yourself, the pane only shows it. - **Low memory kills the dev app.** The dev build holds about 800 MB (Hermes runs the full dev bundle). An AVD that booted from a 2 GB snapshot loses the app to the low-memory killer as soon as a picker or Chrome opens (`lowmemorykiller: Kill 'com.paradev.mobile'` in logcat). Check `adb shell cat /proc/meminfo`; if `MemTotal` is near 2 GB, restart that AVD with `emulator -avd -port -memory 4096 -no-snapshot-load`. - **The emulator mic.** `adb emu avd hostmicon` feeds the Mac microphone to the AVD, so the speech recogniser hears the room. Speech played through the Mac speakers often reaches it as `NO_SPEECH_DETECTED`, and Google's recogniser needs about 5 s after the mic tap before it listens. ## Input and evidence ```bash adb exec-out screencap -p > shot.png # or: android-dev.sh --shot shot.png adb shell screenrecord /sdcard/run.mp4 # stop with Ctrl-C, then adb pull adb shell uiautomator dump /sdcard/ui.xml && adb pull /sdcard/ui.xml # element bounds for taps adb shell input tap X Y; adb shell input text 'hello'; adb shell input keyevent 4 # 4 = back adb shell am start -a android.intent.action.VIEW -d 'superset://settings' com.paradev.mobile adb logcat -d -s ReactNativeJS:V # JS console adb logcat -d -b crash # native crashes adb shell cmd statusbar expand-notifications # the agent card lives here adb shell cmd locale set-app-locales com.paradev.mobile --locales de-DE # per-app locale adb shell settings put system font_scale 1.3 # large text; reset to 1.0 ``` Maestro runs on Android too: `maestro --device emulator-5554 test `, with `JAVA_HOME` on JDK 17. `apps/mobile/.maestro/flows/dev-sign-in.yml` is the sign-in flow `--user` uses. Maestro 2 rejects a flow where `optional: true` sits beside a command (`Invalid Command Format`); put it inside the command's map. Check a flow with `maestro check-syntax ` before running it. Reset the locale and font scale, stop Metro (`--stop`) and the services, and remove test data when done. Leave the emulator running if another agent is waiting for it.