| name | android-debug |
| description | Debug Android Flutter apps including runtime errors, build issues, device connection problems, and performance issues. Use when troubleshooting Android-specific problems, crashes, or deployment issues. |
Android App Debugging Skill
Expert guidance for debugging Android Flutter applications, covering runtime errors, build issues, device connectivity, and performance problems.
When to Use This Skill
- App crashes or runtime errors on Android
- Build failures in Android-specific code
- Device/emulator connection issues
- Performance problems (lag, memory, battery)
- Platform channel issues
- Native Android integration bugs
- APK/App Bundle generation problems
Debugging Workflow
1. Identify the Problem Type
Runtime Errors: App crashes, exceptions, unexpected behavior
Build Errors: Gradle failures, dependency conflicts, compilation errors
Device Issues: Cannot connect, not detecting device
Performance Issues: Slow UI, memory leaks, battery drain
2. Gather Information
flutter doctor -v
flutter devices
flutter run --verbose
flutter logs
3. Common Debug Commands
Device Connection
adb devices
adb kill-server
adb start-server
adb connect <device-ip>:5555
adb shell getprop ro.build.version.release
App Debugging
flutter install
flutter run -d <device-id> --verbose
r (in running flutter session)
R (in running flutter session)
P (in running flutter session)
Log Analysis
flutter logs | grep -i "flutter"
adb logcat -s flutter
adb logcat -c
adb logcat > debug.log
4. Common Issues and Solutions
Build Failures
Issue: Gradle build fails
flutter clean
cd android
./gradlew clean
cd ..
flutter pub get
flutter build apk
Issue: Dependency conflicts
cd android
./gradlew app:dependencies
cd android
./gradlew wrapper --gradle-version=8.0
Issue: Java version mismatch
java -version
export JAVA_HOME=/path/to/java17
Runtime Crashes
Issue: App crashes on startup
- Check logs:
flutter logs
- Look for stack traces
- Check
AndroidManifest.xml permissions
- Verify minimum SDK version in
android/app/build.gradle.kts
Issue: Platform channel errors
- Verify method names match between Dart and Kotlin/Java
- Check parameter types are compatible
- Add null safety checks
- Review platform-specific code in
android/app/src/main/kotlin/
Performance Issues
Issue: UI lag or jank
flutter run --profile
flutter run --profile --trace-skia
Issue: Memory leaks
- Use Flutter DevTools Memory tab
- Check for retained references
- Dispose controllers properly
- Review image caching
Issue: Large APK size
flutter build apk --analyze-size
5. Using Flutter DevTools
flutter pub global activate devtools
flutter pub global run devtools
flutter run --devtools
DevTools Features:
- Inspector: Widget tree visualization
- Timeline: Performance profiling
- Memory: Heap snapshots and leak detection
- Network: HTTP request monitoring
- Logging: Real-time log viewing
- Debugger: Breakpoints and step debugging
6. Android-Specific Debug Tools
Android Studio
- Open
android/ folder in Android Studio
- Use Android Profiler for deep analysis
- Run layout inspector
- Use APK Analyzer
ADB Commands
adb shell screencap /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell screenrecord /sdcard/demo.mp4
adb shell dumpsys package com.cmwen.private_chat_hub
adb shell am force-stop com.cmwen.private_chat_hub
adb shell pm clear com.cmwen.private_chat_hub
adb shell top | grep flutter
Common Error Patterns
Gradle Errors
- Solution: Clean build, check Java version, update dependencies
- Files to check:
android/build.gradle.kts, android/app/build.gradle.kts
Permission Errors
- Solution: Add permissions to
AndroidManifest.xml
- File:
android/app/src/main/AndroidManifest.xml
Native Code Errors
- Solution: Check Kotlin/Java code in platform channels
- Files:
android/app/src/main/kotlin/
Resource Errors
- Solution: Check drawable/mipmap resources
- Files:
android/app/src/main/res/
Best Practices
- Always check Flutter doctor first:
flutter doctor -v
- Use verbose logging:
flutter run --verbose or flutter build apk --verbose
- Clean before rebuild:
flutter clean when in doubt
- Check device connection:
flutter devices and adb devices
- Read full stack traces: Don't just look at the first error
- Test on multiple Android versions: Emulators for API 21, 29, 33+
- Use profile mode for performance:
flutter run --profile
- Enable DevTools: Best for deep debugging
Quick Troubleshooting Checklist
Additional Resources