Troubleshooting - ApplETS/Notre-Dame GitHub Wiki

🆘 Troubleshooting & FAQ

Résolutions aux problèmes courants rencontrés lors du développement.


Renouveler les certificats Apple

Suivre la procédure de ce répertoire, accessible uniquement par les groupes admin et devops.

❌ Erreurs de Build

"Package not found" / "Import error"

Symptôme :

Error: Could not find package 'notredame'.

Solution :

# Nettoyer le cache
flutter clean

# Réinstaller les dépendances
flutter pub get

# Régénérer le code
flutter pub run build_runner build

"Type 'X' is not a subtype of type 'Y'"

Symptôme :

Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'List<Course>'

Cause : Cast de type incorrect ou JSON mal parsé

Solution :

// ❌ MAUVAIS
List<Course> courses = jsonData;  // Crash!

// ✅ BON
List<Course> courses = (jsonData as List)
    .map((c) => Course.fromJson(c))
    .toList();

🔄 Problèmes de State Management

"setState() called after dispose()"

Symptôme :

setState() called after dispose():
This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree.

Cause : Callback appelé après que le widget soit détruit

Solution :

@override
void dispose() {
  subscription?.cancel();  // Annuler les streams
  timer?.cancel();        // Annuler les timers
  super.dispose();
}

@override
void setState(VoidCallback fn) {
  if (mounted) {  // Vérifier que le widget est toujours là
    super.setState(fn);
  }
}

🌐 Problèmes Réseau

"Failed to connect to the server"

Symptôme :

DioException: The server has not indicated when the request should be retried

Cause : Problème réseau ou URL incorrecte

Solution :

// Vérifier la connectivité
final connectivity = locator<ConnectivityService>();
if (!await connectivity.isConnected()) {
  throw NetworkException('No internet connection');
}

// Vérifier l'URL
print('API URL: ${apiClient.baseUrl}');

// Ajouter un retry avec Dio
dio.interceptors.add(
  RetryInterceptor(
    dio: dio,
    logger: Logger(),
    logPrint: print,
  ),
);

"Certificate verify failed" (HTTPS)

Symptôme :

DioException: Certificate verify failed

Cause : Certificat SSL invalide ou problème de configuration

Solution :

// ⚠️ SEULEMENT en développement!
Dio dio = Dio(BaseOptions(
  validateStatus: (status) => status! < 500,
));

// HttpClient personnalisé
final httpClient = HttpClient();
httpClient.badCertificateCallback = 
    (X509Certificate cert, String host, int port) => true;

🎨 Problèmes UI

"RenderFlex overflowed by XXX pixels on the bottom"

Symptôme :

A RenderFlex overflowed by 45 pixels on the bottom.

Cause : Contenu qui dépasse l'espace disponible

Solution :

// ❌ MAUVAIS
Column(
  children: [
    // Contenu qui dépasse
  ],
)

// ✅ BON: Utiliser SingleChildScrollView
SingleChildScrollView(
  child: Column(
    children: [
      // Contenu
    ],
  ),
)

// OU Expanded pour remplir l'espace
Expanded(
  child: ListView(
    children: [
      // Contenu
    ],
  ),
)

🧪 Problèmes de Test

"Mockito: Could not generate mocks"

Symptôme :

Error: Could not generate mocks for this library.

Cause : Classe non-mockable ou configuration build_runner

Solution :

# Nettoyer et regénérer
flutter pub run build_runner clean
flutter pub run build_runner build

# Ou forcer la génération
flutter pub run build_runner build -v

"Test timeout"

Symptôme :

Test execution timed out after 30 seconds.

Cause : Opération asynchrone pas complétée


"The Mock instance returned different type than expected"

Symptôme :

type 'Mock' is not a subtype of type 'CourseRepository'

Cause : Mock pas généré correctement

Solution :

// ✅ Utiliser @GenerateNiceMocks
import 'package:mockito/annotations.dart';

@GenerateNiceMocks([
  MockSpec<CourseRepository>(),
  MockSpec<AuthService>(),
])
void main() { /* ... */ }

// Regénérer
flutter pub run build_runner build

📱 Problèmes de Plateforme

"Android: Gradle sync failed"

Symptôme :

Gradle sync failed with no such file or directory

Solution :

# Nettoyer les fichiers de build
flutter clean
rm -rf android/.gradle
rm -rf build/

# Réinstaller
flutter pub get
flutter pub run build_runner build

# Ou via Android Studio
# Clic droit sur \"android\" → \"Flutter\" → \"Flutter Clean\"

"iOS: CocoaPods error"

Symptôme :

CocoaPods error: The dependency 'X' could not be satisfied

Solution :

# Mettre à jour CocoaPods
sudo gem install cocoapods
pod repo update

# Nettoyer et réinstaller
flutter clean
rm -rf ios/Pods
rm ios/Podfile.lock
flutter pub get
cd ios && pod install && cd ..

🔍 Debugging Advanced

Analyser les Logs

# Afficher tous les logs
flutter logs

# Filtrer par niveau
flutter logs --grep=\"E\"  # Erreurs seulement

# Ou depuis adb
adb logcat | grep flutter

Performance Profiling

# Ouvrir DevTools
flutter pub global run devtools

# Ou directement
flutter pub global run devtools --port 9100

# Puis ouvrir
# http://localhost:9100?uri=http://localhost:40323/XXXXXXXXXXXXXXXX/

Memory Leaks

// ✅ S'assurer de libérer les ressources
@override
void dispose() {
  streamSubscription?.cancel();
  timer?.cancel();
  controller?.dispose();
  super.dispose();
}

Cette page a été en partie générée avec l'aide de Claude Haiku 4.5

⚠️ **GitHub.com Fallback** ⚠️