status-react/scripts/run-android.sh
Siddarth Kumar c44ba69676
fix: we need to tunnel 8081 for connected devices (#18862)
`make run-android` would fail for connected Android devices because the android device was not able to talk to metro bundler.
This was discovered by @J-Son89
This was easily fixed by reverse tcping port 8081.

## Review notes
connect Android device by USB or Wifi
- `make run-clojure`
- `make run-android`
status app must run without any errors on the connected Android device.

we also replace during install on emulator.

otherwise on old emulators `make run-android` fails with :

```
adb: failed to install ./result/app-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install im.status.ethereum.debug without first uninstalling.]
```
2024-02-20 00:52:29 +05:30

31 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
ADB_INSTALL_LOG_FILE="${GIT_ROOT}/logs/adb_install.log"
ADB_SHELL_MONKEY_LOG_FILE="${GIT_ROOT}/logs/adb_shell_monkey.log"
# Generate android debug build.
export ANDROID_ABI_INCLUDE=$("${GIT_ROOT}/scripts/adb_devices_abis.sh")
export BUILD_ENV=debug
export BUILD_TYPE=debug
"${GIT_ROOT}/scripts/build-android.sh"
# Install the APK on running emulator or android device.
installAndLaunchApp() {
adb install -r ./result/app-debug.apk > "${ADB_INSTALL_LOG_FILE}" 2>&1
"${GIT_ROOT}/scripts/wait-for-metro-port.sh" 2>&1
# connected android devices need this port to be exposed for metro
adb reverse "tcp:${RCT_METRO_PORT}" "tcp:${RCT_METRO_PORT}"
adb shell monkey -p im.status.ethereum.debug 1 > "${ADB_SHELL_MONKEY_LOG_FILE}" 2>&1
}
showAdbLogs() {
cat "${ADB_INSTALL_LOG_FILE}" >&2;
cat "${ADB_SHELL_MONKEY_LOG_FILE}" >&2;
}
trap showAdbLogs EXIT ERR INT QUIT
installAndLaunchApp &
exec "${GIT_ROOT}/scripts/run-metro.sh" 2>&1