An Android translation app built with Jetpack Compose and ML Kit. Multi-module clean architecture with live conversation translation, camera translation, and language management capabilities.
- β Live Conversation Translation: Real-time speech-to-speech translation with microphone input
- β Text Input Translation: Manual text translation with history, copy to clipboard, and TTS playback
- β Camera Translation (NEW!): Real-time camera text recognition and translation with AR-style overlay
- β Language Management: Download and delete ML Kit translation models to manage offline storage
- β Runtime Permissions: Comprehensive camera and microphone permission handling with visual feedback
- β Expressive Material3 Theme: Modern design with lavender/purple palette and large corner radii
- β Adaptive UI: Material3 design with NavigationSuiteScaffold for different screen sizes
- β Reusable Components: Custom LanguagePicker with dialog and button variants
- β Clipboard Integration: Copy translations directly to system clipboard
- β Text-to-Speech: Speak both original and translated text in any supported language
Development Phase: β Core Features Complete
- β Navigation structure with adaptive NavigationSuiteScaffold
- β Hilt dependency injection fully configured
- β Stable build system with AGP 8.13.0
- β ML Kit translate integration with model management
- β All core services implemented (Translation, Speech Recognition, TTS)
- β All feature screens implemented with ViewModels
- β Runtime permission management
- β Modern Material3 UI with no deprecated APIs
- Architecture: Multi-module clean architecture (:core, :data, :app)
- UI: Jetpack Compose with Material3 Expressive Theme and adaptive navigation
- Pattern: MVVM with StateFlow and Hilt dependency injection
- Translation: ML Kit Translate API with offline model management
- Persistence: Room database for conversation history
- Camera: CameraX for preview and image analysis
- OCR: ML Kit Text Recognition v2 for camera text detection
- Speech: Android SpeechRecognizer + TextToSpeech integration
- Navigation: NavigationSuiteScaffold (adaptive for phone/tablet/desktop)
- Build: Gradle with Version Catalogs and KSP
- Permissions: Runtime permission handling with Accompanist Permissions
- Testing: JUnit + Hilt Testing + Compose UI Testing
This app supports Android devices with 16KB memory pages (ARM64):
- ML Kit libraries: Latest versions with 16KB compatibility
- Room database: 2.7+ with automatic page size handling
- Native libraries: Verified for 16KB alignment
- Tested on: Android 15+ ARM64 emulators with 16KB pages
- Compliance: Ready for Google Play 16KB page size requirements
Data Preservation: Existing user data remains intact - no migration required. Room 2.7+ automatically handles page size differences.
- Android Studio: Latest stable (tested with Ladybug+)
- AGP: 8.13.0 (stable build, Hilt-compatible)
- Min SDK: 29 (Android 10)
- Target SDK: 36
- Kotlin: 2.2.20 (latest stable)
- KSP: 2.2.20-2.0.2 (matching Kotlin version)
- Hilt: 2.57.2
- JVM Target: 17 (Java & Kotlin aligned - LTS version)
This project uses optimized build settings for faster CI/CD execution:
# gradle.properties
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8 -XX:+UseParallelGC
org.gradle.parallel=true # Parallel module compilation
org.gradle.caching=true # Incremental build cache
org.gradle.autoconfigured=true # On-demand configurationCI/CD Optimizations:
- Parallel builds across :core, :data, :app modules
- Build cache enabled for incremental compilation
- Job-level timeouts prevent runaway builds (30min max)
- Step-level timeouts for granular control
--no-daemonflag for predictable CI execution
This project uses a stable, tested build configuration:
// All plugins properly configured in app/build.gradle.kts:
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android) // Required for Kotlin compilation
alias(libs.plugins.kotlin.compose) // Compose compiler plugin
alias(libs.plugins.ksp) // For Hilt annotation processing
alias(libs.plugins.hilt) // Hilt dependency injection
}
// JVM target aligned between Java and Kotlin
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
// All dependencies managed through libs.versions.toml version catalog-
Clone the repository
git clone https://github.com/patricklarocque1/GlobalTranslation.git cd GlobalTranslation -
Build the project
# PowerShell .\gradlew build # Bash ./gradlew build
-
Run on device/emulator
.\gradlew installDebug
New Architecture: Clean separation into :core (domain), :data (implementation), :app (UI)
GlobalTranslation/
βββ :core (Pure Kotlin) β
NEW
β Domain models, interfaces, and business logic
β - ConversationTurn model
β - Provider interfaces (Translation, Speech, TTS, OCR, Camera)
β - ConversationRepository interface
β - TextBlockGroupingUtil + unit tests
β
βββ :data (Android Library) β
NEW
β Data layer with Room persistence and ML Kit implementations
β - Provider implementations (ML Kit, Android APIs)
β - Room database (ConversationDatabase, DAO, entities)
β - RoomConversationRepository
β - Hilt modules (DataModule, ProviderModule)
β
βββ :app (Android App)
UI layer with Compose screens and ViewModels
- MainActivity with NavigationSuiteScaffold
- 4 feature screens (Conversation, Text Input, Camera, Languages)
- All ViewModels using :data providers β
Migration Complete
- Material3 Expressive Theme
:appdepends on:coreand:data:datadepends on:core:corehas no dependencies (pure Kotlin)
- Testability: Pure Kotlin :core module enables fast unit tests
- Separation of Concerns: Clear boundaries between domain, data, and UI
- Reusability: :core and :data can be shared with Wear OS or other platforms
- Build Performance: Parallel module compilation
- Maintainability: Enforced architecture through module boundaries
- StateFlow Best Practices: All ViewModels use proper immutable StateFlow exposure
private val _uiState = MutableStateFlow(UiState()) val uiState: StateFlow<UiState> = _uiState.asStateFlow()
- Dependency Injection: Constructor injection with Hilt throughout
- Resource Management: Proper cleanup in ViewModel
onCleared() - Coroutines: All async operations use
viewModelScope
π All Documentation: See
docs/README.mdfor complete documentation index
- Quick Reference: See
docs/ai-agents/QUICK-REFERENCE.md- Essential patterns and commands - Architecture Patterns: See
docs/ai-agents/copilot-instructions.md- Detailed implementation guide - Code Analysis Rules: See
docs/ai-agents/copilot-analysis-rules.instructions.md- Error prevention - Project Plan: See
docs/planning/Project Plan.md- Complete implementation history - Testing Strategy: Comprehensive ViewModels with StateFlow testing patterns
- Hilt Setup: Complete dependency injection with services module
- Cursor Rules: See
.cursorrulesin root - Immediate patterns and build config - Copilot Instructions: See
.github/copilot-instructions.md- Primary configuration (GitHub standard location) - Detailed Guide: See
docs/ai-agents/copilot-instructions.md- Comprehensive guide - Integration Guide: See
docs/ai-agents/AI-AGENT-INTEGRATION.md- How all docs work together - Analysis Rules: See
docs/ai-agents/copilot-analysis-rules.instructions.md- Debugging workflows
The app uses a clean provider pattern with interfaces in :core and implementations in :data:
-
TranslationProvider (MlKitTranslationProvider) β
- ML Kit integration with model download and deletion
- Caches active translators for performance
- Handles model download with WiFi conditions
- Properly checks model download status using
RemoteModelManager - Auto-downloads models on first translation (WiFi required)
- Delete downloaded models to free storage space
-
SpeechProvider (AndroidSpeechProvider) β
- Android SpeechRecognizer with permission handling
- Flow-based API for reactive speech recognition
- Proper error handling and cleanup
-
TextToSpeechProvider (AndroidTextToSpeechProvider) β
- TTS with language-specific initialization
- Flow-based speech events
- Lifecycle-aware cleanup
-
TextRecognitionProvider (MlKitTextRecognitionProvider) β
- ML Kit Text Recognition for OCR
- Processes images and extracts text blocks with bounding boxes
- Returns hierarchical DetectedText structure (blocks > lines)
- Proper resource cleanup
-
CameraTranslationProvider (MlKitCameraTranslationProvider) β
- Combined OCR + Translation pipeline
- Processes camera frames through recognition pipeline
- Translates detected text blocks in parallel (async + awaitAll)
- Returns TranslatedTextBlock with original + translated text
- Model availability checking before translation
Architecture: All ViewModels inject provider interfaces from :core, Hilt provides :data implementations
-
ConversationScreen: Live voice translation with Room persistence β
- Uses
ConversationViewModelwith providers from :data - Real-time speech recognition feedback
- Auto-play translation support
- Pull-to-refresh to view saved conversation history from Room database
- Saved history management with delete functionality
- Conversation history persisted to Room database
- Uses
-
TextInputScreen: Manual text translation with full features β
- Uses
TextInputViewModelwith providers from :data - Translation history with timestamps
- Copy to clipboard and copy to input functionality
- Text-to-speech for both original and translated text
- Speak button integration matching conversation screen
- Clear history and clear input buttons
- Uses
-
CameraScreen: Real-time camera translation with OCR β
- Uses
CameraViewModelwith CameraTranslationProvider from :data - CameraX preview with lifecycle management
- Permission request UI with runtime handling
- Real-time text detection and translation with throttling
- Flash toggle and language selection controls
- Processing indicator and error handling
- Document-style translation display
- Uses
-
LanguageScreen: ML Kit model management β
- Uses
LanguageViewModelwith TranslationProvider from :data - Material 3 HorizontalCenteredHeroCarousel showcasing popular language pairs
- Real-time network status indicator (WiFi/Cellular/Offline)
- WiFi-only download toggle in settings card
- Dynamic download status checking
- Download models for offline translation
- Delete models to free storage space
- Cancel in-progress downloads
- 20+ supported languages
- Uses
Migration Complete: All ViewModels now use :data providers instead of legacy :app services
-
StateFlow Pattern: All ViewModels follow immutable state exposure best practices
- Private
MutableStateFlowfor internal updates - Public
StateFlowwith.asStateFlow()for external consumption - Single source of truth maintained across all features
- Private
-
Testing Infrastructure: Production-ready test framework with 100% ViewModel coverage
- 55 unit tests across 4 ViewModels (CameraViewModel: 17, ConversationViewModel: 30, TextInputViewModel: 5, LanguageViewModel: 3)
- Hilt-based dependency injection for tests
- Fake providers prevent flaky tests (no real DataStore/network dependencies)
- All tests reset state in
@Beforesetup for isolation - Material3 semantics handled correctly (useUnmergedTree patterns)
- Comprehensive error handling coverage (translation failures, speech errors, TTS errors)
- Async operations tested with
runTestandadvanceUntilIdle()
-
Reusable Components: LanguagePicker dialog and button variants
-
Runtime Permissions: Comprehensive RECORD_AUDIO and CAMERA permission handling
-
Modern APIs: Material3 throughout with no deprecated API usage
-
Resource Management: Proper cleanup in
onCleared()prevents memory leaks
The app is feature-complete and follows Android best practices:
β Implemented Features - Production-Ready
- Live conversation translation with Room persistence
- Manual text input translation with history, TTS, and clipboard
- Camera translation with real-time OCR (CameraX + ML Kit)
- Offline translation model management (download/delete)
- Material3 Expressive Theme with lavender/purple palette
- Multi-module clean architecture (:core, :data, :app)
- 16KB page size support for Google Play compliance
- Modern, adaptive Material3 UI
- Comprehensive error handling and permissions
β Architecture Quality
- Multi-module clean architecture with provider pattern
- All ViewModels migrated to :data providers (Oct 10, 2025)
- StateFlow best practices in all ViewModels
- Room database for conversation persistence
- Proper Hilt dependency injection throughout
- Resource cleanup preventing memory leaks
- Coroutine-based async operations with automatic cancellation
- Type-safe state management with data classes
- 100% ViewModel test coverage (55 unit tests across all ViewModels)
- Optimized CI/CD pipeline with parallel builds and caching
β Verified Implementation
- All 4 ViewModels using provider pattern from :data
- Navigation uses adaptive NavigationSuiteScaffold
- No deprecated API usage
- Test infrastructure with fake providers
- Full build pipeline working (debug, release, sixteenKB variants)
The planned core features are implemented. See docs/planning/FEATURE_PLAN.md for
potential future enhancements (not currently in active development):
- Face-to-Face Mode (split-screen conversation)
- AI Practice with Gemini (conversational learning)
- Image Translation (upload/translate images)
- Phrasebook (saved translations with categories)
- Enhanced UI/UX (promotional cards, advanced animations)
Note: These are optional future features. Planned core features are implemented and working.
Model Download Status Accuracy (Fixed)
- Issue: Languages screen showed incorrect download status
- Cause: Checking models by attempting translation (which auto-downloaded)
- Fix: Now uses
RemoteModelManager.getInstance()to check actual status - Impact: Accurate download status, better error messages, clear WiFi guidance
Text Input Copy/Speak Functionality (Fixed)
- Issue: Copy and speak buttons were TODO placeholders, not functional
- Cause: TextToSpeechService not injected, clipboard not integrated
- Fix: Added TTS injection, clipboard manager, and proper callbacks
- Impact: Full feature parity with conversation screen, improved UX
Model Deletion Feature (Implemented)
- Issue: Remove button was a TODO placeholder
- Cause: No deleteModel() method in TranslationService
- Fix: Added deletion support using RemoteModelManager
- Impact: Users can free storage space by removing unused models
Error: Plugin [id: 'com.google.devtools.ksp', version: '2.2.20-1.0.20'] was not found
Solution: KSP changed their versioning scheme from 1.0.x to 2.0.x. For Kotlin 2.2.20, use KSP 2.2.20-2.0.2:
# In gradle/libs.versions.toml
ksp = "2.2.20-2.0.2" # Not 1.0.20!Error: Inconsistent JVM-target compatibility detected
Solution: Ensure both Java and Kotlin target the same JVM version:
// In app/build.gradle.kts
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
}
}Error: ClassNotFoundException: com.example.globaltranslation.GloabTranslationApplication
Solution: Ensure the kotlin.android plugin is present:
// In app/build.gradle.kts
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android) // This is required!
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.ksp)
alias(libs.plugins.hilt)
}Then do a clean rebuild:
.\gradlew clean
.\gradlew :app:assembleDebugThis project includes comprehensive documentation for both developers and AI coding assistants:
π Documentation Hub: All documentation is organized in
docs/with clear categories
- Quick Reference Card:
docs/ai-agents/QUICK-REFERENCE.md- Print-friendly patterns cheat sheet - Project Plan:
docs/planning/Project Plan.md- Implementation status and history - Feature Roadmap:
docs/planning/FEATURE_PLAN.md- Future enhancement options - Historical Archive:
docs/archive/- Implementation summaries and bug fix reports - This README: Build setup, troubleshooting, and getting started
- Cursor Rules:
.cursorrules- Quick patterns and critical build config - Copilot Instructions:
.github/copilot-instructions.md- Primary configuration (GitHub standard location) - Detailed Guide:
docs/ai-agents/copilot-instructions.md- Comprehensive architecture guide - Analysis Rules:
docs/ai-agents/copilot-analysis-rules.instructions.md- Error prevention and debugging - Integration Guide:
docs/ai-agents/AI-AGENT-INTEGRATION.md- How all instruction files work together
All documentation is kept synchronized and verified against the actual codebase.
This project is available under the MIT License.