script update
This commit is contained in:
+20
-1
@@ -3,9 +3,13 @@
|
||||
# Ubuntu (22.04+) setup for this React Native 0.81 / Android build (headless or desktop).
|
||||
# Run: bash scripts/setup-ubuntu.sh
|
||||
# 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
|
||||
|
||||
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)
|
||||
COMPILE_SDK_VERSION=36
|
||||
BUILD_TOOLS_VERSION="36.0.0"
|
||||
@@ -74,6 +78,11 @@ fi
|
||||
if [[ "$SKIP_ANDROID" == "true" ]]; then
|
||||
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"
|
||||
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
|
||||
fi
|
||||
|
||||
@@ -120,6 +129,17 @@ echo " Installing packages (this may take a while)..."
|
||||
"ndk;${NDK_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 "==> Shell exports (add to ~/.bashrc or ~/.zshrc):"
|
||||
{
|
||||
@@ -137,7 +157,6 @@ echo "==> Shell exports (add to ~/.bashrc or ~/.zshrc):"
|
||||
echo ""
|
||||
echo "==> Next: open a new shell (or source your rc file), then from the repo:"
|
||||
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 " (If you still see missing codegen/jni, use: ./gradlew :app:assembleRelease --no-configure-on-demand --no-parallel)"
|
||||
|
||||
|
||||
Executable
+33
@@ -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"
|
||||
Reference in New Issue
Block a user