1. Project Scenario Assessment
Before starting development, assess the current project state:
Key Principles:
- Before writing business logic, ensure
./gradlew assembleDebugsucceeds - If
gradle.propertiesis missing, create it first and configure AndroidX
1.1 Required Files Checklist
2. Project Configuration
2.1 gradle.properties
Note: If you encounter
OutOfMemoryErrorduring build, increase-Xmxvalue. Large projects with many dependencies may require 8GB or more.
2.2 Dependency Declaration Standards
2.3 Build Variants & Product Flavors
Product Flavors allow you to create different versions of your app (e.g., free/paid, dev/staging/prod).
Configuration in app/build.gradle.kts:
Build Variant Naming: {flavor}{BuildType} → e.g., devDebug, prodRelease
Gradle Build Commands:
Access BuildConfig in Code:
Note: Starting from AGP 8.0,
BuildConfigis no longer generated by default. You must explicitly enable it in yourbuild.gradle.kts:
Flavor-Specific Source Sets:
Multiple Flavor Dimensions (e.g., environment + tier):
3. Kotlin Development Standards
3.1 Naming Conventions
3.2 Code Standards (Important)
Null Safety:
Exception Handling:
3.3 Threading & Coroutines (Critical)
Thread Selection Principles:
Correct Usage:
Common Mistakes:
3.4 Visibility Rules
3.5 Common Syntax Pitfalls
3.6 Server Response Data Class Fields Must Be Nullable
3.7 Lifecycle Resource Management
3.8 Logging Level Usage
4. Jetpack Compose Standards
4.1 @Composable Context Rules
4.2 State Management
4.3 Common Compose Mistakes
5. Resources & Icons
5.1 App Icon Requirements
Must provide multi-resolution icons:
Recommended: Use Adaptive Icon (Android 8+):
5.2 Resource Naming Conventions
5.3 Avoid Android Reserved Names (Important)
Variable names, resource IDs, colors, icons, and XML elements must not use Android reserved words or system resource names. Using reserved names causes build errors or resource conflicts.
Common Reserved Names to Avoid:
Examples:
6. Build Error Diagnosis & Fixes
6.1 Common Error Quick Reference
6.2 Fix Best Practices
- Read the complete error message first: Locate file and line number
- Check recent changes: Problems usually in latest modifications
- Clean Build:
./gradlew clean assembleDebug - Check dependency versions: Version conflicts are common causes
- Refresh dependencies if needed: Clear cache and rebuild
6.3 Debugging Commands
7. Material Design 3 Guidelines
Review Android UI files for compliance with Material Design 3 Guidelines and Android best practices.
Design Philosophy
M3 Core Principles
M3 Expressive (Latest)
The latest evolution adds emotion-driven UX through:
- Vibrant, dynamic colors
- Intuitive motion physics
- Adaptive components
- Flexible typography
- Contrasting shapes (35 new shape options)
App Style Selection
Critical Decision: Match visual style to app category and target audience.
See Design Style Guide [blocked] for detailed style profiles.
Quick Reference: Key Specifications
Color Contrast Requirements
Touch Targets
8dp Grid System
Typography Scale (Summary)
Animation Duration
Component Dimensions
Anti-Patterns (Must Avoid)
UI Anti-Patterns
- More than 5 bottom navigation items
- Multiple FABs on same screen
- Touch targets smaller than 48dp
- Inconsistent spacing (non-8dp multiples)
- Missing dark theme support
- Text on colored backgrounds without contrast check
Performance Anti-Patterns
- Startup time > 2 seconds without progress indicator
- Frame rate < 60 FPS (> 16ms per frame)
- Crash rate > 1.09% (Google Play threshold)
- ANR rate > 0.47% (Google Play threshold)
Accessibility Anti-Patterns
- Missing contentDescription on interactive elements
- Element type in labels (e.g., "Save button" instead of "Save")
- Complex gestures in kids apps
- Text-only buttons for non-readers
Review Checklist
- 8dp spacing grid compliance
- 48dp minimum touch targets
- Proper typography scale usage
- Color contrast compliance (4.5:1+ for text)
- Dark theme support
- contentDescription on all interactive elements
- Startup < 2 seconds or shows progress
- Visual style matches app category
Design References
8. Testing
Note: Only add test dependencies when the user explicitly asks for testing.
A well-tested Android app uses layered testing: fast local unit tests for logic, instrumentation tests for UI and integration, and Gradle Managed Devices to run emulators reproducibly on any machine — including CI.
8.1 Test Dependencies
Before adding test dependencies, inspect the project's existing versions to avoid conflicts:
- Check
gradle/libs.versions.toml— if present, add test deps using the project's version catalog style - Check existing
build.gradle.ktsfor already-pinned dependency versions - Match version families using the table below
Version Alignment Rules:
Dependencies Reference — add only the groups you need:
Note: If the project uses a Compose BOM,
ui-test-junit4andui-test-manifestdon't need explicit versions — the BOM manages them.
Enable Robolectric resource support in the android block:
8.2 Testing by Layer
See Testing [blocked] for detailed examples, code patterns, and Gradle Managed Device configuration.


