Files
unionflow-server-api/unionflow-mobile-apps/fix-gradle-build.sh
2025-08-20 21:00:35 +00:00

62 lines
2.1 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Script pour résoudre les problèmes de build Gradle Flutter
echo -e "\033[36m🔧 Résolution des problèmes de build Flutter/Gradle...\033[0m"
# 1. Nettoyer le cache Flutter
echo -e "\n\033[33m📦 Nettoyage du cache Flutter...\033[0m"
flutter clean
# 2. Nettoyer le cache Gradle
echo -e "\n\033[33m📦 Nettoyage du cache Gradle...\033[0m"
cd android
if [ -f "gradlew" ]; then
./gradlew clean
fi
cd ..
# 3. Supprimer les dossiers de build
echo -e "\n\033[33m🗑 Suppression des dossiers de build...\033[0m"
rm -rf build
rm -rf android/build
rm -rf android/app/build
rm -rf android/.gradle
rm -rf .dart_tool
# 4. Récupérer les packages Flutter
echo -e "\n\033[33m📥 Récupération des packages Flutter...\033[0m"
flutter pub get
# 5. Vérifier la connexion réseau
echo -e "\n\033[33m🌐 Test de connexion réseau...\033[0m"
if ping -c 1 services.gradle.org &> /dev/null; then
echo -e "\033[32m✅ Connexion à services.gradle.org OK\033[0m"
else
echo -e "\033[31m❌ Impossible de se connecter à services.gradle.org\033[0m"
echo -e "\033[33m Vérifiez votre connexion internet ou les paramètres proxy\033[0m"
# Afficher les variables proxy si elles existent
if [ ! -z "$HTTP_PROXY" ] || [ ! -z "$HTTPS_PROXY" ]; then
echo -e "\n\033[33m📋 Variables proxy détectées:\033[0m"
[ ! -z "$HTTP_PROXY" ] && echo " HTTP_PROXY: $HTTP_PROXY"
[ ! -z "$HTTPS_PROXY" ] && echo " HTTPS_PROXY: $HTTPS_PROXY"
fi
fi
# 6. Test du build
echo -e "\n\033[36m🚀 Test du build Android...\033[0m"
read -p "Voulez-vous lancer le build maintenant? (o/n): " response
if [ "$response" = "o" ] || [ "$response" = "O" ]; then
flutter build apk --debug
if [ $? -eq 0 ]; then
echo -e "\n\033[32m✅ Build réussi!\033[0m"
else
echo -e "\n\033[31m❌ Le build a échoué\033[0m"
echo -e "\n\033[33m💡 Essayez ces commandes manuellement:\033[0m"
echo " 1. cd android"
echo " 2. ./gradlew assembleDebug --offline"
echo " (mode offline si problème réseau)"
fi
fi
echo -e "\n\033[36m✨ Script terminé!\033[0m"