Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From prototype to production: shipping AI featu...

From prototype to production: shipping AI features in your Android app

Getting Gemini working in your Android app takes an afternoon. Getting it ready for real users is where things get serious: exposed API keys, abusive clients burning through your quota, prompts frozen inside a released APK, and no visibility into what your AI feature is actually doing in the wild. This session tackles the production gap. Using Firebase AI Logic, you will call Gemini directly from Kotlin with no backend to build, then harden it for launch: block unauthorized clients with App Check, update prompts and model configuration server-side without shipping a new APK using Server Prompt Templates, and track usage, latency, and cost with AI Monitoring. Finally, we will look ahead to hybrid inference: how the same API prepares your app to run Gemini Nano on-device, so your AI features can work offline, respond faster, and cost less. Ship AI features you can trust in production, and be ready for what comes next.

Avatar for Rosário P. Fernandes

Rosário P. Fernandes

October 07, 2026

More Decks by Rosário P. Fernandes

Other Decks in Programming

Transcript

  1. From prototype to production Shipping AI features in your Android

    app Droidcon Berlin, October, 2026 Miguel Ramos Rosário Fernandes Senior Product Manager Firebase @Google Developer Relations Engineer Firebase @Google 1
  2. What gen AI experience are you building? Proofreading content (grammar

    and spelling  Summarize a long text   errors) Generate or modify images based on a description Rewrite a text with specific tone or style  Find the timestamp of a specific scene in a  Generate a short description of a given image  criteria Recommend items from a list based on simple  Generate a transcription from an audio file  Translating text between different languages  Generate an audio from a text  video Analyze patterns from a small text and extract  data info AI conversation with video/audio  Real-time input & output Solving self-contained & well-defined tasks
  3. Common Challenges & Needs  API Key Security Gemini API

    keys must never reside on client devices, as they can be easily extracted from binaries or intercepted in transit.  Updating Models Hardcoding model names and prompts in binaries breaks app features when older models are decommissioned and end users don't update their apps.  File Privacy File uploads lack user-level access controls, risking cross-user data exposure, and not enforcing per-user security boundaries before sending files to the model.
  4. Service layer < /> Gemini API providers Google Gen AI

    SDK ADK, LangChain, etc It works! You owns a backend though
  5. Android Firebase client SDKs < /> Gemini API providers Firebase

    AI Logic Accelerate the time-to-market and reduce costs
  6. Enable developers to securely add gen AI to client mobile

    and web apps in production Consumer apps (and B2C) running on untrusted devices GA since 2024
  7. import com.google.firebase.Firebase import com.google.firebase.ai.ai @Composable fun MagicBackpackGenerator() { var output

    by remember { mutableStateOf("") } LaunchedEffect(Unit) { 1 val model = Firebase.ai.generativeModel("gemini-3.8-flash") 2 val response = model.generateContent("Write a story about a magic backpack") 3 output = response.text.toString() } MagicBackpackUI(output) }
  8. App Check is not optional Illegitimate request ✓ Gemini API

    providers Firebase AI Logic Legitimate request
  9. class FireTravelApp : Application() { lateinit var appContainer: AppContainer private

    set override fun onCreate() { super.onCreate() if (BuildConfig.DEBUG) { Firebase.appCheck.installAppCheckProviderFactory( 1 DebugAppCheckProviderFactory.getInstance() ) } else { Firebase.appCheck.installAppCheckProviderFactory( 2 PlayIntegrityAppCheckProviderFactory.getInstance() ) } appContainer = AppContainer(this) } } Always configure App Check before any Firebase service
  10. Firebase AI Logic overview Other Product Integrations and features Cloud

    Storage, Remote Config, Model Armor, Live APIs, Hybrid inference, AI Monitoring, etc Firebase Auth Firebase client SDKs < /> Firebase AI Logic P4SA to Google AI and Agent Platform Firebase App Check Gemini API providers Template Storage Storyteller-v1 --model: 'gemini-3-flash' input: schema:... tools:... —-{... P4SA to Gemini APIs on server Cloud Function Triggers Server Prompt Templates
  11. Security Prompt < /> System Instructions You're a storyteller that

    tells nice and joyful stories with happy endings. User Prompts Create a story about a cat with the length of 40 words in Spanish language. Full prompt is in the client, even if you got from Remote Config
  12. Server Prompt Templates Firebase AI Logic Template Storage Storyteller-v1 <

    /> Template Name: Storyteller-v1 Parameters: {cat, 200, English} --model: 'gemini-3-flash' input: schema:... tools:... —-{{role "system"}} You're a storyteller that tells nice and joyful stories with happy endings. Prompt Composer {{role "user"}} Create a story about {{topic}} with the length of {{length}} words in the {{language}} language. Prompt Management and reduce prompt injection Gemini API providers
  13. val generativeModel = Firebase.ai.templateGenerativeModel() val response = generativeModel.generateContent("storyteller-v10", mapOf( "topic"

    to topic, "length" to length, "language" to language ) ) output.value = response.text Your client code
  14. Cloud Triggers Before Generate Content Request < /> Response Request

    Response Gemini API providers After Generate Content
  15. import { beforeGenerateContent } from "firebase-functions/v2/ai"; import { HttpsError }

    from "firebase-functions/v2/https"; export const validateAndFilterPrompt = beforeGenerateContent((event) => { const uid = event.authId; if (event.authType === "unauthenticated" || !uid) { } throw new HttpsError("unauthenticated", "You must be signed in to use this AI service." ); const contents = event.data.request.contents || []; for (const content of contents) { for (const part of content.parts || []) { if (part.text && part.text.toLowerCase().includes("cat")) { } } } throw new HttpsError( "invalid-argument", "Prompts containing the word 'cat' are not allowed." ); return {}; });
  16. Gemini Live API for conversational interactions Firebase AI Logic stream

    audio/video input stream voice response Your mobile or web app using Firebase client SDKs Gemini API providers Live Gemini API
  17. 1 val model = Firebase.ai.liveModel( modelName = "gemini-3.1-flash-live-preview", generationConfig =

    liveGenerationConfig { Reduce the complexity of WebSockets client-server architecture to just a few lines of code responseModality = ResponseModality.AUDIO }, systemInstruction = "Your main job is to change the color...", tools = listOf(Tool.functionDeclarations(listOf(changeColorFunction))) ) val session = model.connect(::handler) 2 session.startAudioConversation(::handler) 3 session.stopAudioConversation() 4
  18. Hybrid model inference Firebase AI Logic Privacy, cost, and off-line

    scenarios Client SDKs Intelligent Routing Local first, Cloud first, Only local, On Device Inference In Cloud Inference Firebase AI Logic iOS Foundation Models Android Gemini Nano (others) Chrome Gemini Nano (others) Gemini API providers
  19. import com.google.firebase.Firebase import com.google.firebase.ai.ai @Composable fun MagicBackpackGenerator() { var output

    by remember { mutableStateOf("") } LaunchedEffect(Unit) { 1 val model = Firebase.ai.generativeModel(modelName = "gemini-3.8-flash", onDeviceConfig = OnDeviceConfig(mode = InferenceMode.PREFER_ON_DEVICE) 2 val response = model.generateContent("Write a story about a magic backpack") 3 output = response.text.toString() } MagicBackpackUI(output) }
  20. Karrot The Challenge After launching in North America, Karrot found

    that 30% of users in the region set their devices to a non-English language, such as Spanish. Karrot needed to make its hyperlocal marketplace accessible to Spanish and other non-English speaking communities. The AI Solution Integrated Firebase AI Logic to deliver natural-sounding, cloud-based translations of marketplace listings and chat messages. The team went from proof of concept (built in under three hours) to production in two weeks, with no dedicated backend. Business Impact 2.4x 1 in 3 More likely to start a chat with a seller (buyers offered translation vs. those not offered) Non-English-language users shown the translation banner actively used the feature TECH STACK: Firebase AI Logic, Gemini Flash-Lite, Vertex AI
  21. The Challenge The AI Solution Users were reluctant to type

    long reviews on mobile, leading to sparse, unhelpful feedback for travelers. Voice-to-text reviews in native languages with Gemini-powered summarization. Business Impact +57% Review Length Higher User Engagement Boosted Customer Trust TECH STACK: Powered by Firebase AI Logic & Gemini Flash for rapid, high-speed iteration.
  22. Call to action 01 Start building. Deploy with the same

    confidence as the thousands of apps today on the production tools. Use App Check, Server 02 Lean Prompt Templates, AI Monitoring, and much more your experience. Let us know how we can 03 Share improve the product
  23. Friendly Meals GET THE SAMPLE APP Scan to clone the

    repository github.com/FirebaseExtended/FriendlyMeals-Android