Jetpack Compose + Google AI Studio Playbook: Gemini Security, Baseline Profiles & Closed Testing

Take a modern Kotlin 2.1+ & Jetpack Compose Material 3 app powered by Gemini / Firebase AI Logic from Android Studio to Google Play Production — locking down API keys with Play Integrity, generating Baseline Profiles, and running 12-tester QA.

./gradlew :app:generateBaselineProfile :app:bundleRelease
import android.app.Application
import com.google.firebase.Firebase
import com.google.firebase.appcheck.appCheck
import com.google.firebase.appcheck.playintegrity.PlayIntegrityAppCheckProviderFactory
import com.google.firebase.initialize

class ComposeAiApp : Application() {
    override fun onCreate() {
        super.onCreate()
        Firebase.initialize(this)
        // Enforce hardware-backed Play Integrity before calling Firebase AI Logic (Gemini):
        Firebase.appCheck.installAppCheckProviderFactory(
            PlayIntegrityAppCheckProviderFactory.getInstance()
        )
    }
}

Graduating From AI Studio Prototype Key to Play Integrity Attestation

Google AI Studio and Gemini in Android Studio make prototyping multimodal Kotlin + **Jetpack Compose** apps remarkably fast: drop an image, stream structured JSON from `gemini-2.5-flash`, and render Material 3 cards in 80 lines of code. Yet the exact pattern used in starter templates (`GenerativeModel(apiKey = BuildConfig.apiKey)`) is unsafe for any APK uploaded to Google Play.

Before cutting your Closed Testing release, migrate your Gemini client either to **Firebase AI Logic** enforced by **Firebase App Check (`PlayIntegrityAppCheckProviderFactory`)** or behind your own Cloudflare Worker / Cloud Run proxy verifying user tokens + Play Integrity verdicts (`MEETS_DEVICE_INTEGRITY`). Crucially, copy your **Play App Signing SHA-256** fingerprint from Play Console into Firebase Project Settings so Play-signed Closed Testing splits pass attestation seamlessly.

Simultaneously, add a 1-tap `Flag / Report AI Response` icon on every generated Compose card to satisfy `/declarations/ai-generated-content-policy`, and disclose prompt/media transmission inside `/declarations/data-safety-and-account-deletion`.

Eliminating Compose Cold-Start & Scroll Jank with ART Baseline Profiles

On a flagship Pixel 9 Pro, unoptimized Jetpack Compose lazy lists feel effortless; on a budget Cortex-A55 handset during Closed Testing or Play Pre-Launch crawls, first-run JIT compilation and unnecessary recompositions (`List<T>` unstable collection parameters without Strong Skipping / `@Immutable`) cause visible stutter.

Enable Kotlin 2.0+ Compose Compiler Strong Skipping (on by default in modern Kotlin), attach `androidx.profileinstaller:profileinstaller`, and package a Baseline Profile (`baseline-prof.txt`) inside your `.aab` so Play Store Cloud Profiles ahead-of-time (AOT) compile critical startup and chat-scroll paths at install time.

Proving Native Quality Across 14 Days of Human + ARM64 ADB QA

Once your Compose `.aab` is approved on Closed Testing and `testers@gootester.com` is verified (starting GOOtester's service clock), run a 12-tester ($6 Basic), 15-tester ($12 Standard), or 25-tester ($20 Premium) human cohort alongside Standard/Premium's isolated physical-device ARM64 ADB QA (`dumpsys gfxinfo` frame percentiles + `meminfo` PSS).

Shipping `versionCode 2` and `versionCode 3` with measurable frame-time and UX improvements builds clear, truthful engineering evidence for your Production Access submission (decided solely by Google Play).