Prerequisites
Before setting up the EV Sum 2 app, ensure you have the following installed and configured:Development environment
Android Studio
Latest stable version with Kotlin plugin
Java Development Kit
JDK 11 or higher (required for compilation)
Android SDK
SDK 24 (Nougat) through SDK 36 support
Git
Version control for cloning the repository
Build configuration
The app requires the following SDK versions as defined inapp/build.gradle.kts:
app/build.gradle.kts
Firebase setup
The app uses Firebase Authentication and Cloud Firestore for backend services. Follow these steps to set up your Firebase project:Create a Firebase project
- Go to the Firebase Console
- Click Add project
- Enter a project name (e.g., “EV Sum 2”)
- Follow the setup wizard to create your project
Register your Android app
In your Firebase project:
- Click the Android icon to add an Android app
- Enter the package name:
com.demodogo.ev_sum_2 - Add an app nickname (optional)
- Click Register app
Download google-services.json
After registering your app:
- Download the
google-services.jsonfile - Place it in the
app/directory of your project:
Enable Firebase Authentication
In the Firebase Console:
- Navigate to Build > Authentication
- Click Get started
- Go to the Sign-in method tab
- Enable Email/Password authentication
- Click Save
Enable Cloud Firestore
In the Firebase Console:
- Navigate to Build > Firestore Database
- Click Create database
- Select Start in test mode (for development)
- Choose your preferred location
- Click Enable
For production, configure proper security rules. Test mode allows all reads/writes and should only be used during development.
Required permissions
The app requires several runtime permissions defined inAndroidManifest.xml:
app/src/main/AndroidManifest.xml
Permission details
RECORD_AUDIO
RECORD_AUDIO
Required for: Voice input via speech-to-textThis permission allows the app to capture audio from the device microphone for dictating email addresses, passwords, and phrases. The app uses Android’s built-in SpeechRecognizer with intelligent normalization.User impact: Users will be prompted at runtime when they first tap a microphone icon to use voice input.
ACCESS_FINE_LOCATION
ACCESS_FINE_LOCATION
Required for: Precise GPS coordinatesEnables high-accuracy location tracking using
FusedLocationProviderClient. Provides latitude and longitude with meter-level precision.User impact: Users will be prompted when accessing location features. Essential for reverse geocoding functionality.ACCESS_COARSE_LOCATION
ACCESS_COARSE_LOCATION
Required for: Approximate location dataProvides city-level location accuracy as a fallback when fine location isn’t available or needed.User impact: Requested alongside fine location. Improves compatibility with different device configurations.
Handling permission requests
The app handles permissions at runtime following Android best practices. Location permissions are requested when users navigate to location features:LocationRepository.kt (example pattern)
Project structure
Understand the codebase organization before making changes:Key architectural components
Repositories
Handle all async Firebase operations using Kotlin Coroutines. Examples include
AuthRepository, PhraseRepository, and LocationRepository.Services
Abstract hardware interactions like GPS, microphone, and TTS. Wrapped with proper error handling for
SecurityException and hardware failures.Domain models
Pure Kotlin data classes with no framework dependencies. Includes
AppUser, Phrase, and DeviceLocation.UI layer
Built entirely with Jetpack Compose and Material Design 3. Uses
NavHost for navigation and Flow for reactive state.Dependencies
The app uses modern Android libraries defined inapp/build.gradle.kts:
Core dependencies
app/build.gradle.kts
Plugin configuration
app/build.gradle.kts
Authentication flow
The app implements a complete authentication system using Firebase Auth with persistent sessions:Auth state monitoring
The
AuthRepository uses AuthStateListener wrapped in a Flow for reactive session management:AuthRepository.kt
Automatic routing
The
RouterScreen component evaluates auth state in real-time:- Logged out: Redirects to
/login - Logged in: Redirects to
/home
Speech normalization
The app includes sophisticated voice input normalization for Spanish speakers:SpeechNormalization.kt
The normalization logic includes spelling mode detection - when 60% or more tokens are single characters, “y” is interpreted as the letter “i” rather than the conjunction.
Testing setup
The project includes unit tests with 100% coverage on critical normalization logic:- Right-click on the test file
- Select Run ‘SpeechNormalizersTest’
Known limitations
- Emulator speech recognition: Google’s recognition engine may fail on emulators without updated Play Store services. Always test voice features on physical devices.
- Ambient noise: The speech recognition system is sensitive to background noise. Best results in quiet environments.
- Language support: Speech normalization is optimized for Spanish (Chilean dialect). Other languages may require custom normalization rules.
Next steps
Architecture deep dive
Learn about the Service-Repository pattern and data flow
Authentication guide
Explore Firebase Auth implementation and session management
Voice input
Understand speech normalization algorithms and testing
Geolocation
Learn about FusedLocationProviderClient and reverse geocoding