# Kotlin & Compose Multiplatform (KMP) Closed Testing Playbook: Android Target, SQLDelight & R8

> Configure `:composeApp` Android targets, Ktor/SQLDelight ProGuard rules, 16 KB JNI alignment, and deterministic `.aab` versioning for Google Play's 12-tester, 14-day closed testing rule.

- **Canonical URL**: https://staging.gootester.com/frameworks/kotlin-multiplatform
- **Config File**: composeApp/build.gradle.kts & gradle/libs.versions.toml
- **Build Command**: `./gradlew :composeApp:bundleRelease --no-daemon --stacktrace`

```kotlin
android {
    namespace = "com.example.kmpapp"
    compileSdk = 36
    defaultConfig {
        applicationId = "com.example.kmpapp"
        minSdk = 24
        targetSdk = 35
        versionCode = 3
        versionName = "1.0.2"
    }
    packaging {
        resources.excludes += "/META-INF/{AL2.0,LGPL2.1}"
    }
    buildTypes.getByName("release") {
        isMinifyEnabled = true
        isShrinkResources = true
        signingConfig = signingConfigs.getByName("release")
        proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
    }
}
```

## Critical Play Console Gotchas
1. **Ktor OkHttp/CIO engine or kotlinx-datetime stripped by Android R8**: Shared commonMain networking and serialization code compiles to JVM bytecode on Android where R8 full mode removes service-loader implementations and companion serializers. Add explicit Ktor, kotlinx.coroutines, and SQLDelight driver keep rules inside composeApp/proguard-rules.pro before bundling.
2. **Conflicting META-INF resources breaking :composeApp:bundleRelease packaging**: Multiplatform libraries such as Ktor, BouncyCastle, Coroutines, or Arrow frequently bundle duplicate META-INF/INDEX.LIST or license metadata files inside transitive JARs. Configure android.packaging.resources.excludes inside composeApp/build.gradle.kts so release Android App Bundle packaging tasks succeed cleanly in CI.
3. **Native SQLite or Cryptography JNI artifacts lacking 16 KB alignment**: While pure Kotlin commonMain compiles to DEX bytecode unaffected by ELF page size, KMP libraries bundling SQLCipher, Realm Kotlin, or custom cinterop JNI .so binaries must upgrade to NDK r28+ for Android 15/16 16 KB compliance.
4. **Hardcoding iOS-centric navigation back gestures without Android Predictive Back**: Compose Multiplatform apps using Voyager, Decompose, or Jetpack Navigation Multiplatform sometimes intercept system back presses improperly on Android 15 and 16. Wire BackHandler or PredictiveBackHandler in androidMain so closed testers never get trapped inside modal sheets.

## Packaging `:composeApp` Shared Modules into Production-Grade Android Bundles

Kotlin Multiplatform (KMP) and Compose Multiplatform let indie teams share domain logic, Ktor networking, SQLDelight/Room Multiplatform persistence, and Material 3 UI across Android, iOS, and Desktop from a single `commonMain` source set. On Android, Gradle compiles both `commonMain` and `androidMain` directly into JVM/DEX bytecode packaged inside `:composeApp:bundleRelease` (or a dedicated `:androidApp` module). Unlike iOS builds compiled via Kotlin/Native LLVM into an `.ipa`, your Android `.aab` runs on ART and undergoes aggressive R8 shrinking, resource optimization, and Play App Signing split-APK slicing.
A frequent pitfall in KMP wizard templates is leaving `buildTypes.getByName("release") { isMinifyEnabled = false }` in `composeApp/build.gradle.kts` to avoid early ProGuard friction. Shipping an unminified KMP Compose Multiplatform bundle balloons download size and degrades startup frame pacing on budget Android phones. Enable `isMinifyEnabled = true` and `isShrinkResources = true`, add ProGuard rules for `io.ktor.**`, `kotlinx.serialization.**`, and your DI container (Koin annotations or Kotlin-Inject), and validate the resulting split APKs via `bundletool` prior to starting your 14-day closed test.
Ensure `applicationId`, `versionCode`, and `versionName` inside `composeApp/build.gradle.kts` follow monotonic Android versioning independent of iOS `CFBundleVersion` strings, allowing you to ship fast Android-specific bugfix bundles during closed testing without Coupling iOS App Store review cycles.

## Android-Specific Lifecycle, Process Death & SQLDelight/Room QA

Developers bringing a Compose Multiplatform codebase from iOS to Google Play often underestimate how aggressively Android OEMs reclaim background processes compared to iOS scene suspension. When a closed tester switches from your KMP app to open a camera or browser on a 4 GB or 6 GB RAM Android phone and returns thirty seconds later, Android may recreate `ComponentActivity` in a fresh process while restoring saved `Bundle` state. ViewModels or Decompose components that store transient IDs only in in-memory Kotlin singletons instead of `SavedStateHandle` or `StateKeeper` crash immediately with `NullPointerException` or blank screens upon restoration.
During GOOtester Standard ($12) and Premium ($20) campaigns, real human closed testers exercise natural multi-app switching across diverse OEM skins while separate automated physical-device ARM64 ADB QA runs capture cold-start telemetry, `dumpsys meminfo` RAM PSS footprints, and `dumpsys gfxinfo` UI frame jank. In accordance with GOOtester's strict provenance separation, automated ADB hardware diagnostics never count toward your 12, 15, or 25 consented human testers.
Also audit `androidMain` database initialization for SQLDelight (`AndroidSqliteDriver`) or Room Multiplatform: ensure schema migrations run on `Dispatchers.IO` rather than blocking `MainActivity.onCreate()` on the main UI thread, preventing startup ANRs in Android Vitals.

## Coordinating 14-Day KMP Closed Testing & Iterative Version Releases

Once your first signed `:composeApp` `.aab` passes initial Play Console track review and you attach `testers@gootester.com` under Closed Testing -> Testers -> Google Groups (remembering to submit any held changes inside Publishing Overview), GOOtester verifies your opt-in link and starts your local service clock. Basic ($6) coordinates 12 testers for 14 days, Standard ($12) coordinates 15 testers for 16 days (14 days + 2 buffer days) plus separate physical-device ADB QA, and Premium ($20) coordinates 25 testers for 24 days (21 days + 3 buffer days) for maximum dropout margin.
Schedule at least two incremental `:composeApp:bundleRelease` updates during your testing window (`versionCode 2` and `versionCode 3`) addressing Android-specific insets, predictive back navigation, or font-scaling edge cases reported by testers, and synchronize each tag via `/api/v1/ci/release` so your final evidence packet aligns cleanly with Google Play's Production Access questionnaire.
Keeping Android release numbers decoupled from iOS TestFlight build numbers inside `gradle.properties` lets you respond to Android closed tester UX reports within hours, building a transparent multi-release changelog without disrupting cross-platform `commonMain` feature velocity.
