diff --git a/Makefile b/Makefile index ce80dea03a..e80117be73 100644 --- a/Makefile +++ b/Makefile @@ -436,10 +436,11 @@ android-clean: ##@prepare Clean Gradle state rm -rf ~/.gradle -android-ports: export FLOWSTORM_PORT := 7722 +android-ports: export FLOWSTORM_PORT ?= 7722 android-ports: export TARGET := android-sdk +android-ports: export RCT_METRO_PORT ?= 8081 android-ports: ##@other Add proxies to Android Device/Simulator - adb reverse tcp:8081 tcp:8081 && \ + adb reverse tcp:$(RCT_METRO_PORT) tcp:$(RCT_METRO_PORT) && \ adb reverse tcp:3449 tcp:3449 && \ adb reverse tcp:4567 tcp:4567 && \ adb reverse tcp:$(FLOWSTORM_PORT) tcp:$(FLOWSTORM_PORT) && \ diff --git a/nix/mobile/android/build.nix b/nix/mobile/android/build.nix index d8b735cf6d..83136dc54b 100644 --- a/nix/mobile/android/build.nix +++ b/nix/mobile/android/build.nix @@ -17,6 +17,7 @@ hermesEnabled ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_hermesEnabled" "true", buildUrl ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_buildUrl" null, statusGoSrcOverride ? lib.getEnvWithDefault "STATUS_GO_SRC_OVERRIDE" null, + reactMetroPort ? lib.getEnvWithDefault "RCT_METRO_PORT" 8081, # If APKs should be split based on architectures androidAbiSplit ? lib.getEnvWithDefault "ANDROID_ABI_SPLIT" "true", # Android architectures to build for @@ -158,6 +159,7 @@ in stdenv.mkDerivation rec { --no-build-cache \ --parallel \ -Dmaven.repo.local='${deps.gradle}' \ + -PreactNativeDevServerPort=${toString reactMetroPort} \ assemble${gradleBuildType} ''; in diff --git a/scripts/check-metro-shadow-process.sh b/scripts/check-metro-shadow-process.sh index 385571253b..32111d0e02 100755 --- a/scripts/check-metro-shadow-process.sh +++ b/scripts/check-metro-shadow-process.sh @@ -6,7 +6,7 @@ if pgrep -f 'shadow-cljs watch mobile' > /dev/null; then exit 1 fi -if pgrep -f 'react-native start' > /dev/null; then +if pgrep -f "react-native start --port=${RCT_METRO_PORT:-8081}" > /dev/null; then echo "Error: make run-metro is already running in another terminal" >&2 echo "Please close that terminal before running this command." >&2 exit 1 diff --git a/scripts/run-metro.sh b/scripts/run-metro.sh index 55c54c9082..c5dca5c785 100755 --- a/scripts/run-metro.sh +++ b/scripts/run-metro.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -if pgrep -f 'react-native start' > /dev/null; then +if pgrep -f "react-native start --port=${RCT_METRO_PORT:-8081}" > /dev/null; then echo "Info: metro is already running in another terminal" else echo "Info: starting a new metro terminal" - react-native start --reset-cache + react-native start --port=${RCT_METRO_PORT:-8081} --reset-cache fi diff --git a/scripts/wait-for-metro-port.sh b/scripts/wait-for-metro-port.sh index 67144cfe5a..ed55f5bf2a 100755 --- a/scripts/wait-for-metro-port.sh +++ b/scripts/wait-for-metro-port.sh @@ -4,7 +4,7 @@ set -euo pipefail TIMEOUT=10 # Metro should not take this long to start. while [ "${TIMEOUT}" -gt 0 ]; do - if ! lsof -i:8081 &> /dev/null; then + if ! lsof -i:"${RCT_METRO_PORT:-8081}" &> /dev/null; then echo "." sleep 1 ((TIMEOUT--))