You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.5 KiB
123 lines
3.5 KiB
#!/bin/bash
|
|
|
|
# Android Test App Setup Script
|
|
echo "🚀 Setting up Android Test App..."
|
|
|
|
# Check if we're in the right directory
|
|
if [ ! -d "android-test" ]; then
|
|
echo "❌ Error: android-test directory not found!"
|
|
echo "Please run this script from the test-apps directory"
|
|
exit 1
|
|
fi
|
|
|
|
cd android-test
|
|
|
|
# Check Node.js version
|
|
echo "🔍 Checking Node.js version..."
|
|
node_version=$(node --version 2>/dev/null)
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Error: Node.js not found!"
|
|
echo "Please install Node.js 18+ from https://nodejs.org/"
|
|
exit 1
|
|
fi
|
|
echo "✅ Node.js version: $node_version"
|
|
|
|
# Install dependencies
|
|
echo "📦 Installing dependencies..."
|
|
npm install
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Error: Failed to install dependencies!"
|
|
exit 1
|
|
fi
|
|
|
|
# Install Capacitor CLI globally if not present
|
|
if ! command -v cap &> /dev/null; then
|
|
echo "🔧 Installing Capacitor CLI globally..."
|
|
npm install -g @capacitor/cli
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Error: Failed to install Capacitor CLI!"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "✅ Capacitor CLI already installed"
|
|
fi
|
|
|
|
# Initialize Capacitor (only if not already initialized)
|
|
if [ ! -f "capacitor.config.ts" ]; then
|
|
echo "⚡ Initializing Capacitor..."
|
|
npx cap init "Daily Notification Android Test" "com.timesafari.dailynotification.androidtest"
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Error: Failed to initialize Capacitor!"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "✅ Capacitor already initialized"
|
|
fi
|
|
|
|
# Add Android platform (only if not already added)
|
|
if [ ! -d "android" ]; then
|
|
echo "📱 Adding Android platform..."
|
|
npx cap add android
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Error: Failed to add Android platform!"
|
|
echo "Make sure Android Studio and Android SDK are installed"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "✅ Android platform already added"
|
|
fi
|
|
|
|
# Build web assets
|
|
echo "🔨 Building web assets..."
|
|
npm run build
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Error: Failed to build web assets!"
|
|
exit 1
|
|
fi
|
|
|
|
# Sync to native
|
|
echo "🔄 Syncing to native..."
|
|
npx cap sync android
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Error: Failed to sync to native!"
|
|
echo "🔧 Attempting to fix Gradle sync issues..."
|
|
|
|
# Fix common Gradle sync issues
|
|
cd android
|
|
./gradlew clean
|
|
./gradlew --stop
|
|
|
|
# Clear Gradle cache if needed
|
|
if [ -d ~/.gradle/wrapper/dists/gradle-9.0-milestone-1* ]; then
|
|
echo "🧹 Clearing incompatible Gradle cache..."
|
|
rm -rf ~/.gradle/wrapper/dists/gradle-9.0-milestone-1*
|
|
fi
|
|
|
|
cd ..
|
|
|
|
# Try sync again
|
|
echo "🔄 Retrying sync..."
|
|
npx cap sync android
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Error: Sync still failing after cleanup"
|
|
echo "📋 See GRADLE_TROUBLESHOOTING.md for manual fixes"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo ""
|
|
echo "✅ Android test app setup complete!"
|
|
echo ""
|
|
echo "📋 Prerequisites check:"
|
|
echo "- Android Studio installed: $(command -v studio &> /dev/null && echo '✅' || echo '❌')"
|
|
echo "- Android SDK configured: $(echo $ANDROID_HOME | grep -q . && echo '✅' || echo '❌')"
|
|
echo ""
|
|
echo "🚀 Next steps:"
|
|
echo "1. Open Android Studio: npx cap open android"
|
|
echo "2. Run on device/emulator: npx cap run android"
|
|
echo "3. Or test web version: npm run dev"
|
|
echo ""
|
|
echo "🔧 Troubleshooting:"
|
|
echo "- If Android Studio doesn't open, install it from https://developer.android.com/studio"
|
|
echo "- If sync fails, check Android SDK installation"
|
|
echo "- For web testing, run: npm run dev"
|
|
|