script update

This commit is contained in:
NishantRajputRN
2026-04-22 15:26:01 +05:30
parent 8d2f5b645c
commit d1b3a045f1
2 changed files with 53 additions and 1 deletions
+20 -1
View File
@@ -3,9 +3,13 @@
# Ubuntu (22.04+) setup for this React Native 0.81 / Android build (headless or desktop). # Ubuntu (22.04+) setup for this React Native 0.81 / Android build (headless or desktop).
# Run: bash scripts/setup-ubuntu.sh # Run: bash scripts/setup-ubuntu.sh
# or: bash scripts/setup-ubuntu.sh --skip-android # if ANDROID_HOME is already set up # or: bash scripts/setup-ubuntu.sh --skip-android # if ANDROID_HOME is already set up
# Fix "SDK location not found" on an existing box: bash scripts/write-android-local-properties.sh
# #
set -euo pipefail set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# Match android/build.gradle (update here if the project changes) # Match android/build.gradle (update here if the project changes)
COMPILE_SDK_VERSION=36 COMPILE_SDK_VERSION=36
BUILD_TOOLS_VERSION="36.0.0" BUILD_TOOLS_VERSION="36.0.0"
@@ -74,6 +78,11 @@ fi
if [[ "$SKIP_ANDROID" == "true" ]]; then if [[ "$SKIP_ANDROID" == "true" ]]; then
echo "==> Skipping Android SDK (--skip-android). Set ANDROID_HOME and ensure SDK/NDK match the project." echo "==> Skipping Android SDK (--skip-android). Set ANDROID_HOME and ensure SDK/NDK match the project."
echo " Required: platforms;android-$COMPILE_SDK_VERSION, build-tools;$BUILD_TOOLS_VERSION, ndk;$NDK_VERSION, cmake;$CMAKE_VERSION" echo " Required: platforms;android-$COMPILE_SDK_VERSION, build-tools;$BUILD_TOOLS_VERSION, ndk;$NDK_VERSION, cmake;$CMAKE_VERSION"
if [[ -n "${ANDROID_HOME:-}" && -d "${ANDROID_HOME}" ]]; then
bash "$SCRIPT_DIR/write-android-local-properties.sh"
else
echo " After setting ANDROID_HOME, run: bash $SCRIPT_DIR/write-android-local-properties.sh"
fi
exit 0 exit 0
fi fi
@@ -120,6 +129,17 @@ echo " Installing packages (this may take a while)..."
"ndk;${NDK_VERSION}" \ "ndk;${NDK_VERSION}" \
"cmake;${CMAKE_VERSION}" "cmake;${CMAKE_VERSION}"
# Gradle requires sdk.dir in android/local.properties (or ANDROID_HOME in every session).
if [[ -f "$SCRIPT_DIR/write-android-local-properties.sh" ]]; then
export ANDROID_HOME
bash "$SCRIPT_DIR/write-android-local-properties.sh" || {
echo " (Could not auto-write local.properties; run: bash $SCRIPT_DIR/write-android-local-properties.sh )"
}
else
printf '## This file is machine-specific (not committed).\nsdk.dir=%s\n' "$ANDROID_HOME" > "${REPO_ROOT}/android/local.properties"
echo "==> Wrote ${REPO_ROOT}/android/local.properties"
fi
echo "" echo ""
echo "==> Shell exports (add to ~/.bashrc or ~/.zshrc):" echo "==> Shell exports (add to ~/.bashrc or ~/.zshrc):"
{ {
@@ -137,7 +157,6 @@ echo "==> Shell exports (add to ~/.bashrc or ~/.zshrc):"
echo "" echo ""
echo "==> Next: open a new shell (or source your rc file), then from the repo:" echo "==> Next: open a new shell (or source your rc file), then from the repo:"
echo " npm ci # or npm install / yarn / pnpm" echo " npm ci # or npm install / yarn / pnpm"
echo " (optional) echo 'sdk.dir=${ANDROID_HOME}' > android/local.properties"
echo " cd android && ./gradlew :app:assembleRelease" echo " cd android && ./gradlew :app:assembleRelease"
echo " (If you still see missing codegen/jni, use: ./gradlew :app:assembleRelease --no-configure-on-demand --no-parallel)" echo " (If you still see missing codegen/jni, use: ./gradlew :app:assembleRelease --no-configure-on-demand --no-parallel)"
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Create android/local.properties with sdk.dir so Gradle finds the Android SDK.
# Run from repo root: ./scripts/write-android-local-properties.sh
# or: ANDROID_HOME=/path/to/Sdk ./scripts/write-android-local-properties.sh
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
ANDROID_DIR="${REPO_ROOT}/android"
LOCAL_PROPS="${ANDROID_DIR}/local.properties"
SDK_DIR="${ANDROID_HOME:-${HOME}/Android/Sdk}"
if [[ ! -d "$SDK_DIR" ]]; then
echo "Error: Android SDK not found at: $SDK_DIR" >&2
echo "Set ANDROID_HOME to your SDK path (e.g. export ANDROID_HOME=\"\$HOME/Android/Sdk\")." >&2
exit 1
fi
if command -v realpath &>/dev/null; then
SDK_DIR=$(realpath "$SDK_DIR")
else
SDK_DIR=$(readlink -f "$SDK_DIR" 2>/dev/null || echo "$SDK_DIR")
fi
if [[ ! -d "$ANDROID_DIR" ]]; then
echo "Error: expected android/ at: $ANDROID_DIR" >&2
exit 1
fi
printf '## This file is machine-specific (not committed). Points Gradle to the Android SDK.\nsdk.dir=%s\n' "$SDK_DIR" > "$LOCAL_PROPS"
echo "Wrote $LOCAL_PROPS"
echo "sdk.dir=$SDK_DIR"