Build Output
The primary debugging tool is the Build Output panel, which shows real-time build logs and errors.Open Build Output
Tap the Build Output tab at the bottom of the screen, or select View → Tool Windows → Build Output.
Code Editor Diagnostics
The editor provides real-time error detection powered by language servers.Java Language Server
- Syntax Errors
- Warnings
- Code Actions
Red underlines indicate compilation errors:Tap the error to see details and quick fixes.
XML Diagnostics
Layout and resource files show validation errors:Problems Panel
View all project errors in one place:- Open View → Tool Windows → Problems
- See categorized issues:
- Errors - Must be fixed before building
- Warnings - Should be addressed
- Info - Suggestions and tips
Logging System
Android Code Studio includes a powerful logging system for runtime debugging.LogSender Integration
For debug builds, the IDE automatically injects a logging plugin:GradleBuildService.kt:306-314
Log Reader
View application logs:Log Levels
Add logging to your code:Log Filtering
Filter logs by:- Level - Verbose, Debug, Info, Warning, Error
- Tag - Your TAG constant
- Package - Your app’s package name
- PID - Process ID
Terminal Debugging
Use the integrated Terminal for command-line debugging.ADB Commands
Gradle Diagnostics
Resource Debugging
Debug resource-related issues:Resource Table
The IDE maintains resource tables for auto-completion and validation:AndroidModule.kt:263-286
Resource Validation
Common resource errors:Resource Not Found
Resource Not Found
- Check
res/values/strings.xmlfor the resource - Ensure the resource name is correct
- Run File → Sync Project with Gradle Files
Duplicate Resources
Duplicate Resources
Invalid Resource Name
Invalid Resource Name
app_name instead of App Name.Layout Inspector
Debug layout issues:- Open your XML layout
- Use the Layout Preview to visualize
- Check for:
- Missing constraints (ConstraintLayout)
- Incorrect dimensions
- Overlapping views
- Missing attributes
Dependency Debugging
Debug dependency resolution issues:View Dependencies
Resolve Conflicts
Force specific versions:app/build.gradle.kts
Build Cache Debugging
Debug cache-related issues:Clear Gradle Cache
Build Cache Reports
Memory Debugging
Monitor and debug memory issues:Heap Dumps
If builds crash with OutOfMemoryError:gradle.properties
Memory Monitoring
Check system memory:Project Sync Issues
Debug project synchronization problems:Validate AGP Version
Ensure Android Gradle Plugin compatibility:
build.gradle.kts
Android Code Studio requires AGP 7.2.0 or newer.
Common Issues
Build Stuck or Hanging
Build Stuck or Hanging
Solution:
- Cancel the build
- Stop Gradle daemons:
- Clear temp files:
- Restart the build
Errors After Gradle Sync
Errors After Gradle Sync
Solution:
- Check the Build Output for specific errors
- Verify all dependencies are available
- Try offline mode if network is unstable:
Language Server Not Working
Language Server Not Working
Solution:
- Close and reopen the file
- Restart the IDE
- Reinstall language servers from Settings
Generated Files Not Found
Generated Files Not Found
Solution:
Generate sources manually:
Debug Configuration
Configure debug settings:app/build.gradle.kts
Performance Profiling
Profile build performance:- Task execution times
- Configuration time
- Dependency resolution time
- Task dependencies
Best Practices
Enable Logging Early
Add logging statements during development, not after encountering issues.
Use Descriptive Tags
Use clear, consistent TAG names for easier log filtering.
Clean Builds
When in doubt, run
./gradlew clean before rebuilding.Check Build Output
Always review build logs for warnings and errors.
Next Steps
- Configure environment variables for debugging
- Use the AI Agent to help diagnose issues
- Optimize builds to reduce errors