#!/bin/bash

echo "🔍 Verifying Android Studio installation..."

# Check Android Studio installation
if [ -d "/Applications/Android Studio.app" ]; then
    echo "✅ Android Studio installed"
else
    echo "❌ Android Studio not found"
fi

# Check Android SDK
if [ -d "$HOME/Library/Android/sdk" ]; then
    echo "✅ Android SDK found at ~/Library/Android/sdk"
    echo "📱 Available SDK platforms:"
    ls "$HOME/Library/Android/sdk/platforms/" 2>/dev/null | head -5
    
    echo "🔧 Available build tools:"
    ls "$HOME/Library/Android/sdk/build-tools/" 2>/dev/null | head -5
else
    echo "❌ Android SDK not found. Please complete Android Studio setup wizard."
fi

# Check Java
if command -v java &> /dev/null; then
    echo "✅ Java installed: $(java -version 2>&1 | head -1)"
else
    echo "❌ Java not found"
fi

# Set environment variables for this session
export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"
export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"

echo "🔄 Testing Flutter with Android toolchain..."
/Users/jettcheng1018/flutter/bin/flutter doctor