# 08. Deployment Guide - YAKKI SMART v2.2
**Date:** 2025-11-30
**Version:** 2.2
**Target Platforms:** Android 13+ (API 33+), iOS 16+ (future)
---
## Table of Contents
1. [Prerequisites](#prerequisites)
2. [Environment Setup](#environment-setup)
3. [Build Configuration](#build-configuration)
4. [Local Development Build](#local-development-build)
5. [Beta Testing (TestFlight / Google Play Beta)](#beta-testing-testflight--google-play-beta)
6. [Production Release](#production-release)
7. [CI/CD Pipeline](#cicd-pipeline)
8. [Monitoring & Analytics](#monitoring--analytics)
9. [Troubleshooting](#troubleshooting)
---
## Prerequisites
### Development Machine Requirements
**Hardware:**
- RAM: 16 GB minimum (32 GB recommended)
- Storage: 50 GB free space (SSD recommended)
- CPU: 8-core processor (Intel i7/i9, AMD Ryzen 7/9, Apple M1/M2)
**Operating System:**
- Windows 10/11 (64-bit)
- macOS 11+ (Big Sur or later)
- Linux (Ubuntu 20.04+ or equivalent)
### Required Software
**1. JDK 17**
```bash
# Verify installation
java -version
# Should output: openjdk version "17.0.x"
# Download from:
# https://adoptium.net/temurin/releases/?version=17
```
**2. Android Studio**
```
Version: Hedgehog (2023.1.1) or later
Download: https://developer.android.com/studio
Components to install:
- Android SDK Platform 36 (API 36)
- Android SDK Platform 33 (API 33 - minSdk)
- Android SDK Build-Tools 34.0.0
- Android Emulator
- Google Play Services
- Google USB Driver (Windows)
```
**3. Git**
```bash
# Verify installation
git --version
# Should output: git version 2.x.x
# Download from: https://git-scm.com/
```
**4. Gradle (bundled with project)**
```bash
# Project uses Gradle Wrapper
./gradlew --version
# Should output: Gradle 8.9
```
### Android Device/Emulator
**Physical Device (recommended for testing):**
- Android 13+ (API 33+)
- 4 GB RAM minimum
- USB Debugging enabled
- Developer Options enabled
**Emulator Configuration:**
```
Device: Pixel 6 Pro
System Image: Android 14 (API 34) - Google APIs
RAM: 4 GB
Internal Storage: 8 GB
```
---
## Environment Setup
### 1. Clone Repository
```bash
# HTTPS
git clone https://github.com/yakki-smart/yakki-smart-android.git
cd yakki-smart-android
# SSH (if you have SSH keys configured)
git clone git@github.com:yakki-smart/yakki-smart-android.git
cd yakki-smart-android
# Verify branch
git branch
# Should show: * main
```
### 2. API Keys Configuration
**Create `local.properties` file:**
```bash
# In project root directory
touch local.properties # Linux/macOS
# or create manually on Windows
```
**Add API keys to `local.properties`:**
```properties
# local.properties (NOT committed to git)
## SDK Location (auto-generated by Android Studio)
sdk.dir=/Users/username/Library/Android/sdk
## API Keys (REQUIRED)
# DeepInfra API Key (for translation)
# Get from: https://deepinfra.com/dash/api_keys
DEEPINFRA_API_KEY=your_deepinfra_key_here
# Gemini API Key (for fallback translation + conductor)
# Get from: https://makersuite.google.com/app/apikey
GEMINI_API_KEY=your_gemini_key_here
# Deepgram API Key (for STT)
# Get from: https://console.deepgram.com/
DEEPGRAM_API_KEY=your_deepgram_key_here
# HuggingFace API Key (for quality assessment)
# Get from: https://huggingface.co/settings/tokens
HUGGINGFACE_API_KEY=your_huggingface_key_here
# Picovoice API Key (for wake word detection)
# Get from: https://console.picovoice.ai/
PICOVOICE_API_KEY=your_picovoice_key_here
## Optional API Keys
# Google Cloud STT API Key (optional)
# Get from: https://console.cloud.google.com/
GOOGLE_CLOUD_API_KEY=your_google_cloud_key_here
# Azure OpenAI API Key (optional, for conductor fallback)
AZURE_OPENAI_API_KEY=your_azure_key_here
AZURE_OPENAI_ENDPOINT=your_azure_endpoint_here
# Together AI API Key (optional)
TOGETHER_API_KEY=your_together_key_here
```
**Security Notes:**
- ✅ `local.properties` is in `.gitignore` (never committed)
- ✅ Keys are injected into `BuildConfig` at build time
- ⚠️ Never commit API keys to version control
- ⚠️ For production, use backend proxy (not direct API keys in APK)
### 3. Google Cloud Credentials (Optional)
If using Google Cloud STT:
```bash
# 1. Download service account key from Google Cloud Console
# 2. Save as: app/src/main/assets/google_cloud_credentials.json
# Example structure:
app/src/main/assets/
├── google_cloud_credentials.json # Your service account key
└── .gitkeep
```
**Security:**
- ✅ `google_cloud_credentials.json` is in `.gitignore`
- ⚠️ Never commit service account keys
- ⚠️ For production, use backend API proxy
### 4. Sync Gradle
```bash
# In Android Studio:
# File → Sync Project with Gradle Files
# Or via command line:
./gradlew build --refresh-dependencies
```
---
## Build Configuration
### Build Variants
```kotlin
// app/build.gradle.kts
android {
buildTypes {
debug {
applicationIdSuffix = ".debug"
versionNameSuffix = "-DEBUG"
isDebuggable = true
isMinifyEnabled = false
// Include all API keys
buildConfigField("String", "DEEPINFRA_API_KEY", "\"${properties["DEEPINFRA_API_KEY"]}\"")
buildConfigField("String", "GEMINI_API_KEY", "\"${properties["GEMINI_API_KEY"]}\"")
// ... all other keys
}
release {
isDebuggable = false
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
// Include only necessary API keys
buildConfigField("String", "DEEPINFRA_API_KEY", "\"${properties["DEEPINFRA_API_KEY"]}\"")
buildConfigField("String", "GEMINI_API_KEY", "\"${properties["GEMINI_API_KEY"]}\"")
// ...
}
}
flavorDimensions += "environment"
productFlavors {
create("dev") {
dimension = "environment"
applicationIdSuffix = ".dev"
versionNameSuffix = "-dev"
}
create("staging") {
dimension = "environment"
applicationIdSuffix = ".staging"
versionNameSuffix = "-staging"
}
create("prod") {
dimension = "environment"
// No suffix for production
}
}
}
```
**Available Build Variants:**
```
1. devDebug - Development debug build
2. devRelease - Development release build
3. stagingDebug - Staging debug build
4. stagingRelease - Staging release build
5. prodDebug - Production debug build
6. prodRelease - Production release build (for Play Store)
```
### ProGuard Rules
**app/proguard-rules.pro:**
```proguard
# Keep production code
# Keep BuildConfig (API keys accessed via reflection)
-keep class com.yakkismart.BuildConfig { *; }
# Keep DomainError sealed class
-keep class com.yakkismart.domain.models.DomainError { *; }
-keep class com.yakkismart.domain.models.DomainError$* { *; }
# Keep UiString sealed interface
-keep interface com.yakkismart.localization.UiString { *; }
-keep class com.yakkismart.localization.UiString$* { *; }
# Keep ViewModel classes
-keep class * extends androidx.lifecycle.ViewModel { *; }
# Keep Hilt components
-keep class dagger.hilt.** { *; }
-keep class javax.inject.** { *; }
-keep class * extends dagger.hilt.android.lifecycle.HiltViewModel { *; }
# Keep Koin modules (SmartRAG)
-keep class org.koin.** { *; }
# Keep ObjectBox entities
-keep @io.objectbox.annotation.Entity class * { *; }
-keep class io.objectbox.** { *; }
# Keep Gemini SDK
-keep class com.google.ai.client.generativeai.** { *; }
# Keep Jakarta Mail
-keep class jakarta.mail.** { *; }
-keep class com.sun.mail.** { *; }
# Keep Apache POI
-keep class org.apache.poi.** { *; }
# Keep ONNX Runtime
-keep class ai.onnxruntime.** { *; }
# Keep Ktor (HTTP client)
-keep class io.ktor.** { *; }
# Remove logging in release
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
}
```
### Signing Configuration
**Create keystore (one-time setup):**
```bash
# Generate release keystore
keytool -genkey -v \
-keystore yakki-smart-release.keystore \
-alias yakki-smart \
-keyalg RSA \
-keysize 4096 \
-validity 10000
# Prompts:
# Enter keystore password: [SECURE_PASSWORD]
# Re-enter: [SECURE_PASSWORD]
# What is your first and last name?: YAKKI SMART
# What is the name of your organizational unit?: Development
# What is the name of your organization?: YAKKI SMART
# What is the name of your City or Locality?: [Your City]
# What is the name of your State or Province?: [Your State]
# What is the two-letter country code for this unit?: [Your Country Code]
```
**Add to `local.properties`:**
```properties
# Keystore configuration (local.properties)
RELEASE_STORE_FILE=../yakki-smart-release.keystore
RELEASE_STORE_PASSWORD=your_keystore_password
RELEASE_KEY_ALIAS=yakki-smart
RELEASE_KEY_PASSWORD=your_key_password
```
**Configure signing in `app/build.gradle.kts`:**
```kotlin
android {
signingConfigs {
create("release") {
storeFile = file(properties["RELEASE_STORE_FILE"] as String)
storePassword = properties["RELEASE_STORE_PASSWORD"] as String
keyAlias = properties["RELEASE_KEY_ALIAS"] as String
keyPassword = properties["RELEASE_KEY_PASSWORD"] as String
}
}
buildTypes {
release {
signingConfig = signingConfigs.getByName("release")
// ... other release config
}
}
}
```
**Security:**
- ⚠️ Store keystore file securely (backup in secure location)
- ⚠️ Never commit keystore to git
- ⚠️ Use strong passwords (16+ characters)
- ⚠️ For CI/CD, use encrypted secrets
---
## Local Development Build
### Debug Build (for development)
```bash
# Build debug APK
./gradlew assembleDebug
# Output:
# app/build/outputs/apk/dev/debug/app-dev-debug.apk
# Install to connected device
./gradlew installDevDebug
# Or use Android Studio:
# Run → Run 'app' (Shift+F10)
```
### Release Build (for testing)
```bash
# Build release APK (requires keystore)
./gradlew assembleProdRelease
# Output:
# app/build/outputs/apk/prod/release/app-prod-release.apk
# Verify signature
jarsigner -verify -verbose -certs app/build/outputs/apk/prod/release/app-prod-release.apk
# Install to device
adb install app/build/outputs/apk/prod/release/app-prod-release.apk
```
### App Bundle (for Play Store)
```bash
# Build Android App Bundle (AAB)
./gradlew bundleProdRelease
# Output:
# app/build/outputs/bundle/prodRelease/app-prod-release.aab
# File size: ~50-70 MB (before Play Store optimization)
# Download size for users: ~30-40 MB (after dynamic delivery)
```
### Run Tests
```bash
# Unit tests
./gradlew test
# Specific module
./gradlew :app:testDebugUnitTest
./gradlew :conductor:test
./gradlew :smartrag3:core:test
# Instrumented tests (requires device/emulator)
./gradlew connectedAndroidTest
# Specific module
./gradlew :app:connectedDevDebugAndroidTest
# Test coverage report
./gradlew jacocoTestReport
# Report: app/build/reports/jacoco/index.html
```
### Lint Checks
```bash
# Run lint
./gradlew lint
# Lint report
# app/build/reports/lint-results-devDebug.html
# Fix auto-fixable issues
./gradlew lintFix
```
### Code Quality
```bash
# Detekt (Kotlin static analysis)
./gradlew detekt
# Report: build/reports/detekt/detekt.html
# ktlint (Kotlin code style)
./gradlew ktlintCheck
# Fix formatting
./gradlew ktlintFormat
```
---
## Beta Testing (TestFlight / Google Play Beta)
### Google Play Console Setup
**1. Create App in Play Console**
- Go to: https://play.google.com/console
- Create Application
- Fill in app details (title, description, screenshots)
**2. Create Beta Testing Track**
```
Play Console → Testing → Closed Testing → Create new release
Track Name: Beta
Countries: Select target countries
Testers: Create tester list (email addresses)
```
**3. Upload Beta Build**
```bash
# Build signed AAB
./gradlew bundleProdRelease
# Upload via Play Console:
# Testing → Closed Testing → Beta → Create new release
# Upload: app/build/outputs/bundle/prodRelease/app-prod-release.aab
# Or use Gradle Play Publisher plugin (automated):
./gradlew publishProdReleaseBundle --track beta
```
**4. Beta Testing Link**
```
Play Console will generate a link like:
https://play.google.com/apps/testing/com.yakkismart
Share this with beta testers.
```
### TestFlight (iOS - future)
```bash
# Note: iOS version not yet implemented
# Placeholder for future iOS deployment
# Steps (when iOS version ready):
# 1. Archive in Xcode
# 2. Upload to App Store Connect
# 3. Add to TestFlight
# 4. Invite testers via email
```
### Beta Testing Checklist
**Before Beta Launch:**
- [ ] Fix all P0 critical issues
- [ ] Test on 3+ physical devices (different manufacturers)
- [ ] Test on Android 13, 14, 15
- [ ] Verify all API keys work
- [ ] Test offline mode
- [ ] Test permissions flow
- [ ] Verify analytics/crashlytics integration
- [ ] Create beta testing guide document
- [ ] Setup feedback channels (Discord, Telegram)
**During Beta (Week 1):**
- [ ] Daily bug triage
- [ ] Monitor crashlytics dashboard
- [ ] Monitor analytics (DAU, retention)
- [ ] Collect user feedback
- [ ] Weekly beta updates (if needed)
**Beta Success Criteria:**
- ✅ 80+ active testers
- ✅ Crash rate <1%
- ✅ Translation success rate >95%
- ✅ Average latency <3s
- ✅ NPS >40
---
## Production Release
### Pre-Release Checklist
**Code Quality:**
- [ ] All P0 issues fixed
- [ ] All unit tests passing
- [ ] All instrumented tests passing
- [ ] Lint checks passing (0 errors)
- [ ] Code coverage >60%
- [ ] ProGuard configuration tested
- [ ] No hardcoded secrets (verify with grep)
**Functionality:**
- [ ] Translator scenario fully functional
- [ ] All 4 languages working (EN, RU, ZH, ES)
- [ ] Wake word detection working
- [ ] Quality assessment working (with BuildConfig API key)
- [ ] Voice commands working
- [ ] Translation history working
- [ ] Settings working
- [ ] Permissions flow working
**Performance:**
- [ ] End-to-end latency <3s (avg)
- [ ] Memory usage <200 MB (avg)
- [ ] Battery drain <5%/hour (active use)
- [ ] APK size <50 MB (AAB before optimization)
- [ ] Cold start time <2s
**Security:**
- [ ] All API keys in BuildConfig (no hardcoded strings)
- [ ] ProGuard enabled (release build)
- [ ] Certificate pinning enabled (optional)
- [ ] Network security config verified
- [ ] No sensitive logs in release build
**Assets:**
- [ ] App icon (all resolutions)
- [ ] Feature graphic (1024x500)
- [ ] Screenshots (phone, tablet) - 6+ images
- [ ] Promotional video (optional, 30s-2min)
- [ ] Privacy policy URL
- [ ] Terms of service URL
**Store Listing:**
- [ ] App title (50 chars max)
- [ ] Short description (80 chars max)
- [ ] Full description (4000 chars max)
- [ ] Keywords/tags
- [ ] Content rating (ESRB, PEGI)
- [ ] Target age group
- [ ] Category (Productivity / Education)
### Production Build
```bash
# 1. Update version in app/build.gradle.kts
versionCode = 1 # Increment for each release
versionName = "1.0.0" # Semantic versioning
# 2. Clean build
./gradlew clean
# 3. Build production AAB
./gradlew bundleProdRelease
# 4. Verify signing
jarsigner -verify -verbose -certs \
app/build/outputs/bundle/prodRelease/app-prod-release.aab
# 5. Test on physical device
bundletool build-apks \
--bundle=app/build/outputs/bundle/prodRelease/app-prod-release.aab \
--output=app-release.apks \
--mode=universal
unzip -p app-release.apks universal.apk > app-release.apk
adb install app-release.apk
# 6. Verify app functionality
# - Test all scenarios
# - Check analytics integration
# - Verify no crashes
```
### Google Play Console Upload
**1. Create Production Release**
```
Play Console → Production → Create new release
Release name: v1.0.0
Release notes:
- Initial public release
- Real-time voice translation
- 4 languages supported (EN, RU, ZH, ES)
- Wake word detection
- Quality assessment
- Translation history
Upload AAB: app/build/outputs/bundle/prodRelease/app-prod-release.aab
```
**2. Staged Rollout (Recommended)**
```
Rollout percentage: 20% (day 1)
→ Monitor for 24-48 hours
→ Increase to 50% (day 3)
→ Monitor for 24-48 hours
→ Increase to 100% (day 5)
Benefits:
- Catch production-only issues early
- Limit impact of critical bugs
- Gradual server load increase
```
**3. Review & Publish**
```
Play Console → Production → Review release
Estimated review time: 1-7 days (usually 1-3 days)
Status updates:
- Pending review
- Under review
- Approved (live on Play Store)
```
### Post-Launch Monitoring (Week 1)
**Daily Monitoring:**
- [ ] Crashlytics dashboard (crash rate <1%)
- [ ] Analytics dashboard (DAU, retention)
- [ ] Play Console reviews (respond within 24h)
- [ ] User feedback channels
- [ ] Server costs (API usage)
**Key Metrics:**
```
DAU (Daily Active Users): Target 500+ (week 1)
Retention (Day 1): Target 40%+
Retention (Day 7): Target 20%+
Crash rate: Target <1%
ANR rate: Target <0.5%
App rating: Target 4.0+
```
**Alerts Setup:**
```
Firebase Crashlytics Alerts:
- Crash rate >2% (critical)
- ANR rate >1% (warning)
- New crash type (info)
Analytics Alerts:
- DAU drops >20% (critical)
- Retention Day 1 <30% (warning)
Cost Alerts:
- API costs >$100/day (warning)
- API costs >$500/day (critical)
```
---
## CI/CD Pipeline
### GitHub Actions Configuration
**`.github/workflows/ci.yml`:**
```yaml
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Create local.properties
run: |
echo "DEEPINFRA_API_KEY=${{ secrets.DEEPINFRA_API_KEY }}" >> local.properties
echo "GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}" >> local.properties
echo "DEEPGRAM_API_KEY=${{ secrets.DEEPGRAM_API_KEY }}" >> local.properties
echo "HUGGINGFACE_API_KEY=${{ secrets.HUGGINGFACE_API_KEY }}" >> local.properties
echo "PICOVOICE_API_KEY=${{ secrets.PICOVOICE_API_KEY }}" >> local.properties
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run lint
run: ./gradlew lint
- name: Run unit tests
run: ./gradlew test
- name: Build debug APK
run: ./gradlew assembleDebug
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: app-debug
path: app/build/outputs/apk/dev/debug/app-dev-debug.apk
```
**`.github/workflows/release.yml`:**
```yaml
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Create local.properties
run: |
echo "DEEPINFRA_API_KEY=${{ secrets.DEEPINFRA_API_KEY }}" >> local.properties
echo "GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}" >> local.properties
# ... all API keys
- name: Decode keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > yakki-smart-release.keystore
echo "RELEASE_STORE_FILE=./yakki-smart-release.keystore" >> local.properties
echo "RELEASE_STORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}" >> local.properties
echo "RELEASE_KEY_ALIAS=${{ secrets.KEY_ALIAS }}" >> local.properties
echo "RELEASE_KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}" >> local.properties
- name: Build release AAB
run: ./gradlew bundleProdRelease
- name: Sign AAB
run: |
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 \
-keystore yakki-smart-release.keystore \
-storepass ${{ secrets.KEYSTORE_PASSWORD }} \
app/build/outputs/bundle/prodRelease/app-prod-release.aab \
${{ secrets.KEY_ALIAS }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: app/build/outputs/bundle/prodRelease/app-prod-release.aab
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload to Play Store
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAY_STORE_SERVICE_ACCOUNT }}
packageName: com.yakkismart
releaseFiles: app/build/outputs/bundle/prodRelease/app-prod-release.aab
track: production
status: completed
inAppUpdatePriority: 2
```
### GitHub Secrets Configuration
```
Repository → Settings → Secrets and variables → Actions
Add secrets:
- DEEPINFRA_API_KEY
- GEMINI_API_KEY
- DEEPGRAM_API_KEY
- HUGGINGFACE_API_KEY
- PICOVOICE_API_KEY
- KEYSTORE_BASE64 (base64 encoded keystore file)
- KEYSTORE_PASSWORD
- KEY_ALIAS
- KEY_PASSWORD
- PLAY_STORE_SERVICE_ACCOUNT (JSON from Play Console)
```
**Encode keystore for GitHub Secrets:**
```bash
base64 -i yakki-smart-release.keystore | pbcopy # macOS
base64 -w 0 yakki-smart-release.keystore # Linux
certutil -encode yakki-smart-release.keystore keystore.txt # Windows
```
---
## Monitoring & Analytics
### Firebase Setup
**1. Create Firebase Project**
```
https://console.firebase.google.com/
→ Add project
→ Project name: YAKKI SMART
→ Enable Google Analytics
```
**2. Add Android App**
```
Project settings → Add app → Android
Package name: com.yakkismart
App nickname: YAKKI SMART
Download google-services.json
Place in: app/google-services.json
```
**3. Enable Services**
```
Firebase Console:
- Analytics (enabled by default)
- Crashlytics (Build → Crashlytics → Enable)
- Performance Monitoring (Build → Performance → Enable)
- Remote Config (Engage → Remote Config → Enable)
```
**4. Add Firebase SDK**
```kotlin
// app/build.gradle.kts
plugins {
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
id("com.google.firebase.firebase-perf")
}
dependencies {
implementation(platform("com.google.firebase:firebase-bom:32.7.0"))
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-crashlytics-ktx")
implementation("com.google.firebase:firebase-perf-ktx")
implementation("com.google.firebase:firebase-config-ktx")
}
```
### Analytics Events
```kotlin
// Log custom events
class AnalyticsService @Inject constructor(
private val firebaseAnalytics: FirebaseAnalytics
) {
fun logTranslation(
sourceLanguage: String,
targetLanguage: String,
provider: String,
latencyMs: Long,
qualityScore: Double
) {
firebaseAnalytics.logEvent("translation") {
param("source_language", sourceLanguage)
param("target_language", targetLanguage)
param("provider", provider)
param("latency_ms", latencyMs)
param("quality_score", qualityScore)
}
}
fun logScenarioUsage(scenario: String) {
firebaseAnalytics.logEvent("scenario_usage") {
param("scenario", scenario)
}
}
fun logError(error: DomainError) {
firebaseAnalytics.logEvent("app_error") {
param("error_type", error::class.simpleName ?: "Unknown")
param("error_message", error.message)
}
}
}
```
### Crashlytics Integration
```kotlin
// Initialize in Application
class YakkiApplication : Application() {
override fun onCreate() {
super.onCreate()
// Set custom keys for debugging
FirebaseCrashlytics.getInstance().apply {
setCustomKey("app_version", BuildConfig.VERSION_NAME)
setCustomKey("build_type", BuildConfig.BUILD_TYPE)
}
}
}
// Log non-fatal exceptions
try {
riskyOperation()
} catch (e: Exception) {
FirebaseCrashlytics.getInstance().recordException(e)
// Handle gracefully
}
// Set user identifier (for debugging)
FirebaseCrashlytics.getInstance().setUserId(userId)
```
### Performance Monitoring
```kotlin
// Trace custom operations
class TranslationService {
suspend fun translate(text: String): String {
val trace = Firebase.performance.newTrace("translation")
trace.start()
try {
val result = performTranslation(text)
trace.putMetric("text_length", text.length.toLong())
trace.putAttribute("provider", "deepinfra")
return result
} finally {
trace.stop()
}
}
}
```
### Remote Config
```kotlin
// Initialize Remote Config
class RemoteConfigService @Inject constructor() {
private val remoteConfig = Firebase.remoteConfig
init {
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 3600 // 1 hour
}
remoteConfig.setConfigSettingsAsync(configSettings)
// Set defaults
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
}
suspend fun fetchConfig() {
remoteConfig.fetchAndActivate().await()
}
fun getQualityThreshold(): Double {
return remoteConfig.getDouble("quality_threshold")
}
fun getProviderPriority(): List<String> {
return remoteConfig.getString("provider_priority").split(",")
}
}
```
---
## Troubleshooting
### Common Build Issues
**Issue 1: Gradle Sync Failed**
```
Error: Could not find com.google.ai.client.generativeai:generativeai:0.9.0
Solution:
1. Check internet connection
2. Clear Gradle cache:
./gradlew clean
./gradlew --stop
rm -rf ~/.gradle/caches
3. Sync again:
./gradlew build --refresh-dependencies
```
**Issue 2: API Key Not Found**
```
Error: Unresolved reference: DEEPINFRA_API_KEY
Solution:
1. Verify local.properties exists
2. Check API key is present:
DEEPINFRA_API_KEY=your_key_here
3. Sync Gradle again
4. Rebuild project:
Build → Rebuild Project
```
**Issue 3: ProGuard Issues**
```
Error: Class not found after ProGuard
Solution:
1. Add keep rule to proguard-rules.pro:
-keep class com.your.package.ClassName { *; }
2. Test release build:
./gradlew assembleProdRelease
3. Use APK Analyzer to inspect obfuscation:
Build → Analyze APK
```
**Issue 4: Out of Memory**
```
Error: OutOfMemoryError: Java heap space
Solution:
1. Increase Gradle heap size in gradle.properties:
org.gradle.jvmargs=-Xmx4096m
2. Enable parallel compilation:
org.gradle.parallel=true
3. Enable configuration cache:
org.gradle.configuration-cache=true
```
### Runtime Issues
**Issue 1: Crash on Launch**
```
Check:
1. Crashlytics dashboard for stack trace
2. Logcat for error messages:
adb logcat | grep "FATAL EXCEPTION"
3. ProGuard mapping file (for obfuscated stack traces)
4. Test on different devices/Android versions
```
**Issue 2: API Calls Failing**
```
Check:
1. API keys in BuildConfig (not hardcoded)
2. Network permissions in AndroidManifest.xml
3. Internet connection on device
4. API quotas/rate limits
5. Backend server status
```
**Issue 3: High Memory Usage**
```
Debug:
1. Android Studio Profiler → Memory
2. Look for memory leaks (ViewModel, Activity)
3. Check large object allocations (bitmaps, models)
4. Use LeakCanary for leak detection:
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.12")
```
---
## Conclusion
**YAKKI SMART v2.2 Deployment Guide** provides comprehensive instructions for building, testing, and deploying the application.
### Quick Start Checklist
**Initial Setup (30 min):**
- [ ] Install Android Studio
- [ ] Clone repository
- [ ] Create local.properties with API keys
- [ ] Sync Gradle
- [ ] Run debug build
**Beta Testing (Week 1):**
- [ ] Fix critical issues (P0-1, P0-2)
- [ ] Build signed AAB
- [ ] Upload to Play Console (Beta track)
- [ ] Invite 100 testers
- [ ] Monitor feedback
**Production Launch (Week 8):**
- [ ] Complete pre-release checklist
- [ ] Build production AAB
- [ ] Upload to Play Console (Production track)
- [ ] Staged rollout (20% → 100%)
- [ ] Post-launch monitoring
### Support
**Documentation:**
- Architecture: `02_ARCHITECTURE.md`
- Features: `04_IMPLEMENTED_FEATURES.md`
- Security: `09_SECURITY.md`
**Issues:**
- GitHub Issues: https://github.com/yakki-smart/yakki-smart-android/issues
- Email: support@yakki-smart.com
---
**Date:** 2025-11-30
**Version:** 2.2
**Target:** Android 13+ (API 33+)
---