#!/bin/bash # Flutter App Start-Skript mit sichtbarem Build-Status # Usage: ./run_app.sh [device_id] set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" # Farben für Output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color echo -e "${BLUE}========================================${NC}" echo -e "${BLUE} HHA Logistics - Flutter App Start ${NC}" echo -e "${BLUE}========================================${NC}" echo "" # Device ID aus Parameter oder Default DEVICE_ID=${1:-"emulator-5554"} # Prüfe ob Flutter installiert ist if ! command -v flutter &> /dev/null; then echo -e "${RED}❌ Flutter wurde nicht gefunden!${NC}" echo "Bitte Flutter installieren: https://flutter.dev/docs/get-started/install" exit 1 fi echo -e "${BLUE}📱 Verfügbare Geräte:${NC}" flutter devices echo "" # Prüfe ob gewähltes Gerät existiert echo -e "${BLUE}🔍 Prüfe Gerät: $DEVICE_ID${NC}" if ! flutter devices | grep -q "$DEVICE_ID"; then echo -e "${YELLOW}⚠️ Gerät '$DEVICE_ID' nicht gefunden!${NC}" echo -e "${YELLOW} Versuche verfügbare Geräte zu finden...${NC}" echo "" # Suche nach Android Emulator AVAILABLE_EMULATOR=$(flutter devices | grep "emulator" | head -1 | awk '{print $2}') if [ -n "$AVAILABLE_EMULATOR" ]; then echo -e "${GREEN}✅ Emulator gefunden: $AVAILABLE_EMULATOR${NC}" DEVICE_ID=$AVAILABLE_EMULATOR else echo -e "${RED}❌ Kein Emulator gefunden!${NC}" echo "" echo "Verfügbare Emulatoren:" flutter emulators echo "" echo -e "${YELLOW}Starte Emulator...${NC}" flutter emulators --launch Pixel_8_Pro_API_29 2>/dev/null || true sleep 5 fi fi echo "" echo -e "${BLUE}📦 Installiere Dependencies...${NC}" flutter pub get echo "" echo -e "${BLUE}🔨 Starte Build...${NC}" echo -e "${YELLOW} Das kann einige Minuten dauern beim ersten Mal!${NC}" echo "" # Zeige Build-Fortschritt mit verbose flutter run -d "$DEVICE_ID" --debug --verbose 2>&1 | while IFS= read -r line; do # Filtere wichtige Build-Schritte if [[ $line == *"Building APK"* ]] || [[ $line == *"Compiling"* ]] || [[ $line == *"Installing"* ]] || [[ $line == *"Launching"* ]]; then echo -e "${GREEN}🔄 $line${NC}" elif [[ $line == *"error"* ]] || [[ $line == *"Error"* ]] || [[ $line == *"FAILED"* ]]; then echo -e "${RED}❌ $line${NC}" elif [[ $line == *"Syncing"* ]] || [[ $line == *"Reloaded"* ]]; then echo -e "${BLUE}💫 $line${NC}" else # Normale Ausgabe nur bei verbose-Modus relevant if [[ $line == *"[+"* ]] || [[ $line == *"lib/"* ]]; then echo "$line" fi fi done echo "" echo -e "${GREEN}========================================${NC}" echo -e "${GREEN} App beendet ${NC}" echo -e "${GREEN}========================================${NC}"