Really good

This commit is contained in:
Eric Ratliff
2026-01-24 13:12:14 -06:00
parent 9bd16f3dd0
commit f69870b87f
2 changed files with 167 additions and 36 deletions

View File

@@ -211,6 +211,9 @@ fi
cd "$(dirname "$PROJECT_DIR")" cd "$(dirname "$PROJECT_DIR")"
echo "" echo ""
# Setup Android SDK (needed for deployment)
setup_android_sdk
# Create project # Create project
echo ">>> Creating project..." echo ">>> Creating project..."
create_project_structure "$PROJECT_DIR" create_project_structure "$PROJECT_DIR"

View File

@@ -160,6 +160,23 @@ cd "$SDK_DIR" || exit 1
# Check for Android SDK configuration # Check for Android SDK configuration
if [ ! -f "local.properties" ] && [ -z "$ANDROID_HOME" ]; then if [ ! -f "local.properties" ] && [ -z "$ANDROID_HOME" ]; then
echo ""
echo "Android SDK not found. Attempting auto-setup..."
# Try to find common Android SDK locations
FOUND_SDK=""
for loc in "$HOME/Android/Sdk" "$HOME/.android-sdk" "$HOME/Library/Android/sdk"; do
if [ -d "$loc" ] && [ -d "$loc/platforms" ]; then
FOUND_SDK="$loc"
break
fi
done
if [ -n "$FOUND_SDK" ]; then
echo "✓ Found Android SDK at $FOUND_SDK"
echo "sdk.dir=$FOUND_SDK" > local.properties
export ANDROID_HOME="$FOUND_SDK"
else
echo "" echo ""
echo "════════════════════════════════════════════════════════════════" echo "════════════════════════════════════════════════════════════════"
echo " Error: Android SDK Not Configured" echo " Error: Android SDK Not Configured"
@@ -167,11 +184,14 @@ if [ ! -f "local.properties" ] && [ -z "$ANDROID_HOME" ]; then
echo "" echo ""
echo "The FTC SDK needs the Android SDK to build APKs." echo "The FTC SDK needs the Android SDK to build APKs."
echo "" echo ""
echo "FIX OPTION 1: Set ANDROID_HOME (recommended)" echo "FIX OPTION 1: Run setup automatically"
echo " Create a new project with ftc-new-project (it will set up Android SDK)"
echo ""
echo "FIX OPTION 2: Set ANDROID_HOME manually"
echo " export ANDROID_HOME=/path/to/android/sdk" echo " export ANDROID_HOME=/path/to/android/sdk"
echo " echo 'export ANDROID_HOME=/path/to/android/sdk' >> ~/.bashrc" echo " echo 'export ANDROID_HOME=/path/to/android/sdk' >> ~/.bashrc"
echo "" echo ""
echo "FIX OPTION 2: Create local.properties" echo "FIX OPTION 3: Create local.properties"
echo " echo 'sdk.dir=/path/to/android/sdk' > ~/ftc-sdk/local.properties" echo " echo 'sdk.dir=/path/to/android/sdk' > ~/ftc-sdk/local.properties"
echo "" echo ""
echo "════════════════════════════════════════════════════════════════" echo "════════════════════════════════════════════════════════════════"
@@ -187,7 +207,7 @@ if [ ! -f "local.properties" ] && [ -z "$ANDROID_HOME" ]; then
echo "" echo ""
echo "4. Note the 'Android SDK Location' path shown" echo "4. Note the 'Android SDK Location' path shown"
echo "" echo ""
echo "5. Use that path in FIX OPTION 1 or 2 above" echo "5. Use that path in FIX OPTION 2 or 3 above"
echo "" echo ""
echo "Typical Android SDK locations:" echo "Typical Android SDK locations:"
echo " • Linux: ~/Android/Sdk" echo " • Linux: ~/Android/Sdk"
@@ -198,6 +218,7 @@ if [ ! -f "local.properties" ] && [ -z "$ANDROID_HOME" ]; then
echo "" echo ""
exit 1 exit 1
fi fi
fi
if ! ./gradlew build; then if ! ./gradlew build; then
echo "" echo ""
@@ -493,3 +514,110 @@ check_prerequisites() {
echo "✓ All prerequisites satisfied" echo "✓ All prerequisites satisfied"
return 0 return 0
} }
# Setup Android SDK automatically
setup_android_sdk() {
local android_sdk_dir="${ANDROID_SDK_DIR:-$HOME/.android-sdk}"
# Check if already configured
if [ -n "$ANDROID_HOME" ] && [ -d "$ANDROID_HOME" ]; then
echo "✓ Android SDK already configured at $ANDROID_HOME"
return 0
fi
if [ -d "$android_sdk_dir" ] && [ -f "$android_sdk_dir/cmdline-tools/latest/bin/sdkmanager" ]; then
echo "✓ Android SDK found at $android_sdk_dir"
export ANDROID_HOME="$android_sdk_dir"
return 0
fi
echo ""
echo ">>> Setting up Android SDK..."
echo "This is needed to build APKs for the Control Hub."
echo "Download size: ~150MB"
echo ""
# Detect OS
local os_type=""
case "$(uname -s)" in
Linux*) os_type="linux" ;;
Darwin*) os_type="mac" ;;
*)
echo "Unsupported OS for auto-setup"
return 1
;;
esac
# Download command-line tools
local tools_url=""
if [ "$os_type" = "linux" ]; then
tools_url="https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip"
else
tools_url="https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip"
fi
echo "Downloading Android SDK command-line tools..."
local temp_zip=$(mktemp -d)/cmdline-tools.zip
if command -v curl &> /dev/null; then
curl -L "$tools_url" -o "$temp_zip" 2>/dev/null || {
echo "Error: Failed to download Android SDK tools"
return 1
}
elif command -v wget &> /dev/null; then
wget -q "$tools_url" -O "$temp_zip" || {
echo "Error: Failed to download Android SDK tools"
return 1
}
else
echo "Error: Need curl or wget to download"
return 1
fi
# Extract
echo "Installing to $android_sdk_dir..."
mkdir -p "$android_sdk_dir/cmdline-tools"
if ! command -v unzip &> /dev/null; then
echo "Error: unzip not found. Install with: sudo apt install unzip"
return 1
fi
unzip -q "$temp_zip" -d "$android_sdk_dir/cmdline-tools"
mv "$android_sdk_dir/cmdline-tools/cmdline-tools" "$android_sdk_dir/cmdline-tools/latest"
rm -rf "$(dirname "$temp_zip")"
export ANDROID_HOME="$android_sdk_dir"
export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin"
# Accept licenses and install essentials
echo "Installing Android SDK components..."
yes | sdkmanager --licenses > /dev/null 2>&1 || true
sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0" > /dev/null 2>&1
# Add to shell RC files for persistence
local shell_rc=""
if [ -n "$BASH_VERSION" ]; then
shell_rc="$HOME/.bashrc"
elif [ -n "$ZSH_VERSION" ]; then
shell_rc="$HOME/.zshrc"
fi
if [ -n "$shell_rc" ] && [ -f "$shell_rc" ]; then
if ! grep -q "ANDROID_HOME.*android-sdk" "$shell_rc"; then
echo "" >> "$shell_rc"
echo "# Android SDK (added by FTC Project Generator)" >> "$shell_rc"
echo "export ANDROID_HOME=\"$android_sdk_dir\"" >> "$shell_rc"
echo "export PATH=\"\$PATH:\$ANDROID_HOME/cmdline-tools/latest/bin:\$ANDROID_HOME/platform-tools\"" >> "$shell_rc"
echo "Note: Added ANDROID_HOME to $shell_rc"
fi
fi
# Create local.properties in FTC SDK
if [ -n "$FTC_SDK_DIR" ] && [ -d "$FTC_SDK_DIR" ]; then
echo "sdk.dir=$android_sdk_dir" > "$FTC_SDK_DIR/local.properties"
fi
echo "✓ Android SDK configured at $android_sdk_dir"
echo ""
}