Share
Build intelligent Android apps with Google's AI
An AI agent adds four AI features to droidconKE, the conference's open-source Android app, live on stage at DevFest Pwani 2026 in Mombasa. Each prompt is pasted from the slides into the agent. The Android CLI and Google's Android skills work with the agent you already use; this talk used Claude Code.
- A summary of your starred sessions, written on the phone by Gemini Nano with the ML Kit Prompt API and structured output
- The same summary on any phone, with Firebase AI Logic hybrid inference
- "Ask the conference": Gemini answers as the app's own session cards, with A2UI on Compose
- "Star this session" as an AppFunction an assistant can call
It also covers what to check before shipping a cloud AI feature: App Check, a Remote Config switch, a spend cap, the Data safety form and R8.
Code: https://github.com/droidconKE/droidconKeKotlin
Harun Wangereka
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
46 slides
-
DevFest Pwani · 28 November 2026 Build intelligent Android apps
with Google’s AI Four AI features, built live into a real app Harun Wangereka Android GDE · Senior Mobile Engineer, SmileID Part of the team organising Droidcon x Fluttercon Kenya -
The app droidconKE gets four AI features droidconKE is the
conference’s open-source app. This year Don, Ian and I maintain it, building on the work of 40 other contributors. Today it learns four new things. 1 A summary of my starred sessions, on the phone Gemini Nano · ML Kit Prompt API 2 The same summary on any phone Firebase AI Logic hybrid: Nano first, else the cloud 3 “Ask the conference”, answered as native cards Firebase AI Logic · A2UI on Compose 4 “Star this session” from the system AppFunctions github.com/droidconKE/droidconKeKotlin Open source · 43 contributors -
AI on Android Three places AI shows up Google groups
AI on Android into three areas. Today’s four features touch all three. In-app intelligence Intelligence system Developer productivity Features inside your app, powered by on-device and cloud models. Your app’s actions, offered to Android and its agents. AI that helps you build the app. Most of today: steps 1 to 3 Step 4 How every step gets built today -
How the demos run We’re building four features in this
session Each one goes from a prompt to the phone. 1 A prompt goes to the agent Each prompt names Google’s Android skill for the job, so the agent follows Android’s own guidance. 2 The agent builds and installs it It uses the Android CLI to build, install and check its own work. 3 The phone shows the result The phone stays on this screen through android device hub. 4 Off until Remote Config turns it on Each feature has its own switch, so it can be turned off again without a release. -
Part 1 · in-app intelligence On the phone Gemini Nano:
no cost per call, works offline, and the data stays on the phone. -
In-app intelligence · on the phone Gemini Nano runs on
the phone Gemini Nano is Google’s model that runs on the phone itself. Apps reach it through ML Kit. It fits when It gives you The catch The input and the answer are short: summarise, rewrite, sort, pull out fields. No cost per call. Works offline. The data never leaves the phone. Only recent flagship phones have it, and the model may need a download first. The list is next. 45% 24% higher conversion for new users less time to complete an order Kakao Mobility case study, Android Developers blog, October 2025 Kakao Mobility, using Gemini Nano on the phone to fill in parcel addresses -
In-app intelligence · on the phone Which phones have Gemini
Nano? Mostly recent flagships. The phone on stage isn’t one, which is why step 2 exists. Brand Phones that can run the Prompt API Google Pixel 9 series · Pixel 10 and 11 series Samsung Galaxy S25 and S26 series · Z Flip7, Z Fold7 and later Xiaomi, POCO, Redmi Xiaomi 15, 15T, 17 series · POCO F7 Ultra, F8 Pro, X7 Pro, X8 Pro OPPO, OnePlus, realme OPPO Find X8 to X10, Find N5, N6, Reno 14 Pro to 16 Pro · OnePlus 13, 15 · realme GT 7 vivo, iQOO vivo X200, X300, X500 series · iQOO 13, 15 Honor, Motorola Honor Magic 7, Magic 8 Pro, 600 Pro · Motorola Edge 70 Pro, Razr 60 Ultra Prompt API device support, developers.google.com/ml-kit/genai, read 28 November 2026. Not the full list. -
ML Kit GenAI Two ways to use Gemini Nano Apps
reach Gemini Nano through ML Kit’s GenAI APIs. They come in two kinds. Ready-made APIs The Prompt API Google wrote the prompt. You call one method. You write the prompt, for anything the ready-made APIs don’t do. Summarisation Image description Proofreading Rewriting Speech recognition Your own prompt Text and images in Text or a Kotlin object out A summary of my starred sessions isn’t a ready-made API, so step 1 uses the Prompt API. -
ML Kit GenAI · Prompt API The Prompt API: your
prompt, on Gemini Nano Send your own prompt to Gemini Nano on the phone and get its answer back. Get the client val model = Generation.getClient() when (model.checkStatus()) { FeatureStatus.AVAILABLE -> { val response = model.generateContent( "Summarise these sessions: …") show(response.candidates[0].text) } FeatureStatus.DOWNLOADABLE -> model.download().collect { /* progress */ } else -> showNoNanoMessage() } com.google.mlkit:genai-prompt · minSdk 26 Generation.getClient() is Gemini Nano, through ML Kit. Check it’s there UNAVAILABLE: this phone can’t run Nano. DOWNLOADABLE: fetch the model first. Send a prompt You get text back. That is the problem on the next slide. -
ML Kit GenAI · Prompt API Text answers vs structured
output Both come from the Prompt API. The difference is what your code gets back. Ask for text "Sure! You’ve starred three Compose sessions and a testing workshop. Two of them clash at 2 pm, so…" Your code has to parse that, and the wording changes on every call. Ask for structured output StarredSummaryOutput( overview = "A day of Compose…", themes = listOf("Compose", "Testing", "AI"), ) A Kotlin object your screen can show directly. The next two slides show how. -
Structured output · 1 of 2 Describe the answer as
a Kotlin class Write a class for the answer. The model fills in its fields. @Generable @Generable data class StarredSummaryOutput( @Guide(description = "What my starred sessions are about") var overview: String = "", @Guide(description = "Up to three recurring topics") var themes: List<String> = emptyList(), ) Marks the class the model fills in. A compiler plugin turns it into a schema. @Guide Tells the model what goes in each field. Setup KSP 2.3.6 or later, and Kotlin only. -
Structured output · 2 of 2 Check, then ask for
that class Check the phone can do it, then ask for the class instead of text. val model = Generation.getClient() if (model.checkStatus() != AVAILABLE || !model.isStructuredOutputFeatureAvailable()) { return SummaryResult.Unavailable } val request = generateTypedContentRequest( GenerateContentRequest.Builder( TextPart(prompt)).build(), StarredSummaryOutput::class, ) val summary: StarredSummaryOutput? = model.generateContent(request) .candidates.firstOrNull()?.response model.close() Check both Nano is ready, and this phone supports structured output. Ask for the class generateTypedContentRequest wraps a normal request. An object, or null Never a string to parse. Close the client when you’re done. -
Live · step 1 of 4 Phone: OPPO CPH2113 ·
no Gemini Nano Step 1: a summary written on the phone Gemini Nano summarises my starred sessions, and the answer comes back as a Kotlin object. 1 Paste this into Claude Code Use the ml-kit-genai-prompt-api skill. On Home, add a card that summarises my starred sessions, written on the phone by Gemini Nano with structured output into a Kotlin class. If this phone can't run Gemini Nano, say so on the card instead of hiding it. Match the app's existing Home cards, with the design system's AiCube in the card header, thinking while the summary loads. Put it behind a new Remote Config switch that is off by default, following the cube_hero_enabled pattern. Then run the unit tests and stabilityCheck, and install it on the OPPO phone. 2 While it builds, meet the agent’s tools The Android CLI and Google’s skills, next. Then back to the phone. -
While the agent works · developer productivity The Android CLI
and skills How the agent knows Android instead of guessing. -
The tools What is the Android CLI? Android’s whole toolchain
in one command, for you and your agent. For you For agents For CI Any terminal. No Android Studio. Built for agents, with Google’s skills. Same commands, JSON output. Works with any agent harness Antigravity · Claude Code · Codex · Cursor · Copilot · Gemini · 70+ more -
The tools Everything the Android CLI can do Every command
starts with android. The agent runs the same ones you do, so you can check its work. Set up Build and inspect Run and drive init sdk install skills list · add docs search build describe analyze preview render run · install layout · screen input tap · scroll emulator Phones and measuring device hub device remote profiler signals -
Google’s official Android skills The skills behind today’s steps A
skill is a folder of Google’s instructions for one Android job. The agent reads it before it writes code. Skill What it teaches the agent Where android-cli The Android CLI, so it can build, run and check Every step ml-kit-genai-prompt-api Gemini Nano, structured output, prefix caching Step 1 appfunctions Exposing app actions to the system Step 4 r8-analyzer Finds the rules that hold R8 back. Reports only Before you ship No skill yet for Firebase’s hybrid API or A2UI, so steps 2 and 3 are built from the docs. android skills add --all --agent=claude-code --project=. -
Android skills A skill is a folder the agent reads
Open one up and it is plain text: what to do, in order, and the traps to avoid. What it tells the agent to do The step 1 skill ml-kit-genai-prompt-api/ SKILL.md references/ get-started.md structured-output.md prefix-caching.md prompt-optimization.md SKILL.md says what the skill is for and the steps to follow. The agent reads it when your request matches. 1 Set minSdk to 26 and add the Prompt API 2 Check Gemini Nano is ready; download it if not 3 Return a @Generable type, not a string 4 Cache the prompt’s prefix when it’s long 5 Close the model when the screen goes -
Step 1 · result Phone: OPPO CPH2113 · no Gemini
Nano Most phones can’t run Gemini Nano This phone can’t, like most in this room. The card says so instead of failing. 1 Open Home on the phone Once the agent says it has installed the build. 2 Read the card “This phone can’t run Gemini Nano, so there’s no on-device summary.” 3 That is step 2’s job Send the same request to the cloud when Nano isn’t there. -
Part 2 · in-app intelligence In the cloud, and both
Most phones can’t run Gemini Nano. Firebase AI Logic sends the same request to Gemini in the cloud. -
Live · step 2 of 4 Phone: OPPO CPH2113 ·
no Gemini Nano Step 2: the same summary on any phone Firebase’s hybrid mode: Gemini Nano when the phone has it, Gemini in the cloud when it doesn’t. 1 Paste this into Claude Code Switch the starred-sessions summary to Firebase AI Logic hybrid inference: InferenceMode.PREFER_ON_DEVICE, with gemini-3.5-flash as the cloud model. Follow firebase.google.com/docs/ai-logic/hybrid, and check class names in the library itself, because firebaseai-ondevice isn't in the Firebase BoM. Keep the same summary type, label whether the phone or the cloud wrote it, and with no Nano and no network say why on the card. Keep the same switch, then install it on the OPPO phone. 2 While it builds How Firebase AI Logic and hybrid inference work, next. Then back to the phone. -
In-app intelligence · in the cloud Firebase AI Logic: Gemini
from the app The app calls Gemini in the cloud straight from the phone, with no backend of your own. Any phone val model = Firebase.ai( backend = GenerativeBackend.googleAI(), ).generativeModel( modelName = "gemini-3.5-flash", ) val response = model.generateContent(prompt) show(response.text) Longer context and stronger reasoning than on the phone. No backend The app calls Gemini through Firebase. App Check keeps others off your quota. The cost A price per request, and a trip over the network. -
In-app intelligence · hybrid Pick a mode. Firebase picks the
model. Firebase chooses for you: Gemini Nano when the phone has it, the cloud when it doesn’t. @OptIn(PublicPreviewAPI::class) val model = Firebase.ai( backend = GenerativeBackend.googleAI(), ).generativeModel( modelName = "gemini-3.5-flash", onDeviceConfig = OnDeviceConfig( mode = InferenceMode.PREFER_ON_DEVICE), ) val response = model.generateObject( StarredSummaryOutput.firebaseAISchema(), prompt) val where = response.response.inferenceSource Mode Runs on PREFER_ON_DEVICE Nano if ready, else the cloud PREFER_IN_CLOUD The cloud; Nano when offline ONLY_ON_DEVICE Nano, or an error ONLY_IN_CLOUD The cloud, or an error -
Step 2 · while it builds Before a cloud call
reaches real users Step 2 sends data to Gemini and costs money per request. Three things keep that safe. App Check on A switch, off by default A spend cap Only your real app, on a real phone, can call Gemini on your quota. Remote Config turns the feature on, and off again without a release. Set a budget in Firebase. AI Monitoring shows every cloud call. Once App Check is enforced, Firebase refuses AI Logic calls without it. This app’s App Check went in before step 1. -
Step 2 · result Phone: OPPO CPH2113 · no Gemini
Nano Now every phone gets a summary This phone has no Nano, so the cloud wrote it, and the card says which. 1 Open Home on the phone Once the agent says it has installed the build. The summary appears a little after launch. 2 Read the footer “Summarised in the cloud by Gemini”. 3 Airplane mode on, reopen the app The card says why there is no summary. Then airplane mode off. -
Part 3 · agentic UI Answers you can tap Until
now, an agent could only answer in text. Agent-to-UI (A2UI) lets it answer with UI that your app draws. -
Agentic UI · A2UI, short for Agent-to-UI The agent describes
the UI. Your app draws it. Gemini answers with a description of the UI. Your app draws it, using only components it allows. Agent A2UI message Your catalog Gemini answers with a list of components, as data. Card · Text · Button, as data. No code. The list of components you allow, drawn by your Compose code. Without it With it Hand-written UI for every kind of answer, and an app update each time the agent learns something new. Native, on-brand cards for answers you didn’t plan for. Taps go back to the agent. -
Agentic UI · A2UI on Compose How A2UI runs in
a Compose app Google’s A2UI renderer for Compose is in AndroidX, in alpha. From Gemini’s answer to a tap: Gemini A2uiMessageProcessor A2uiSurface Answers with A2UI messages, as JSON Checks each message against your catalogs Draws the answer with Compose Back to the agent A2uiActionInterceptor Someone taps Star Only if your code sends it. Step 3 just logs it. Your code sees the tap first: Star saves the session dispatchAction(…) sends the event androidx.a2ui.compose · material3-a2ui 1.0.0-alpha02 · A2UI spec 0.9.1 · developer.android.com/develop/ui/compose/agentic -
Agentic UI · the catalog Your catalog: what the agent
may draw A catalog lists the components the agent may use: Material 3’s Basic Catalog, plus your own. AskCatalog.kt, step 3 val catalog = A2uiCatalog( catalogId = ID, components = listOf( MaterialA2uiBasicCatalogV1Defaults.column, MaterialA2uiBasicCatalogV1Defaults.text, SessionCardComponent, // the app's own card ), ) // Gemini learns the catalog from its schema val schema = catalog.toJsonSchemaString() The Basic Catalog Material 3 components, ready to use: Button Card TextField CheckBox DateTimeInput Divider Column Icon Tabs Row Slider List Text ChoicePicker Modal Image Step 3 uses two of them, plus its own SessionCard. -
Agentic UI · your own component Add your own component
to the catalog The agent sends a session id. The app draws its own session card, with live data. object SessionCardComponent : A2uiComponent { override val name = "SessionCard" override val properties = listOf(sessionId) @Composable override fun A2uiComponentScope.Content( properties: A2uiComponentProperties, modifier: Modifier, ) { SessionsCard( session = sessionFor(properties[sessionId]), onBookmark = { dispatchAction(starAction(it)) }, ) } } A name and properties What the agent sees in the schema. Here, only a session id. Your Compose code It draws the app’s shared SessionsCard, so answers look like the rest of the app. Taps go back dispatchAction sends Star as an event. -
Agentic UI · on screen Process the answer, then draw
it A processor turns Gemini’s messages into surfaces. Compose draws each one. val processor = A2uiMessageProcessor( catalogs = listOf(AskCatalog.catalog), interceptors = listOf(starInterceptor), ) // Gemini's answer, one A2UI message at a time messages.forEach { processor.processInput(parser, it) } // In the screen LazyColumn { items(surfaces, key = { it.id }) { A2uiSurface(surfaceModel = it) } } Your catalogs The processor rejects anything not in them. An interceptor Sees each tap first. Star becomes bookmarkSession, and never reaches Gemini. Surfaces processor.activeSurfaces is a StateFlow. Draw each with A2uiSurface. -
Demo · step 3 of 4 Phone: OPPO CPH2113 ·
no Gemini Nano Step 3: ask the conference Questions answered with the app’s own session cards. Built before the talk, because it takes a while to build. 1 Paste this into Claude Code Install the prebuilt step 3 app on the OPPO phone with adb install -r, from ~/AndroidStudioProjects/SmileID/v12/DevFest-2026/Build Intelligent Android Apps/apks/step3.apk. Don't build anything or switch branches in this checkout. Then open the app on the phone. 2 When it opens: Home → Ask the conference Tap the suggestion “What is on after lunch on the last day?” 3 Tap the star, then the card The star saves the session. The card opens it. -
Part 4 · the intelligence system Let Android call your
app AppFunctions: an assistant stars a session without opening the app. -
Intelligence system · AppFunctions Let Android’s assistant act in your
app AppFunctions let an assistant run an action in your app without the app being open. @AppFunctionServiceEntryPoint( serviceName = "StarSessionAppFunctionService", appFunctionXmlFileName = "star_session_…", ) abstract class BaseStarSessionAppFunctionService : AppFunctionService() { /** Stars a conference session so it appears * in the user's starred sessions. */ @AppFunctionDeclaration(isDescribedByKDoc = true) suspend fun starSession(sessionId: String): StarredSession { … } } The KDoc is the description It’s what an assistant reads to decide when to call the function. KSP does the rest It generates the real service and the schema Android reads. Only safe actions What your UI already lets people do. Nothing destructive. -
Live · step 4 of 4 Emulator: small_phone · Android
16 QPR2 Step 4: star a session from outside the app An AppFunction any assistant on the phone can call. The agent plays the assistant. 1 Paste this into Claude Code: start the emulator Start the small_phone emulator with the Android CLI, and tell me when it has finished booting. 2 Then paste this: build step 4 Use the appfunctions skill. Expose Star this session as an AppFunction that calls SessionsRepo.bookmarkSession, with a KDoc an assistant can understand. Declare both manifest properties the skill shows, including android.app.appfunctions.schema. Install it on the small_phone emulator and check it appears in adb shell cmd app_function list-app-functions. 3 While it builds The function’s KDoc is what an assistant reads to decide when to call it. -
Step 4 · try it Emulator: small_phone · Android 16
QPR2 Play the assistant An assistant calls the function without opening the app. Here the agent makes the same call with adb. 1 Paste this into Claude Code Play the assistant on the small_phone emulator: find the droidconKE function in adb shell cmd app_function list-app-functions, then call it with adb shell cmd app_function execute-app-function to star session 1112, and show me what it returned. Put the whole device command in double quotes, so the JSON's quotes survive adb shell. 2 Open droidconKE on the emulator “Welcome & State of the Community” is starred, and the app was never opened. 3 Then paste this: an id the app doesn’t have Now call it again for session 9999999. It’s refused: “No session has the ID 9999999.” -
Part 5 Before you ship An AI feature is still
a release: privacy, release builds and R8. -
Before you ship Two more checks before release The switch,
App Check and spend cap came with step 2. Two things are left. Data safety must match Test on a release build Cloud calls send user data to Google. Update the Play Data safety form before release, or the listing can be pulled. R8 shrinks release builds, and it can break how an AI answer is parsed. Debug builds won’t show it. -
Before you ship · R8 R8 tidies your app when
you build a release R8 is the build step that shrinks and optimises a release, and every AI library adds work for it. Removes Renames Rewrites Code and images nothing uses. Long names become short ones. Same work, fewer steps. 35% 30% 9% fewer “App not responding” errors fewer slow app starts smaller download Monzo’s results after turning R8 on fully, as shared at Google I/O 2026 -
Before you ship · R8 Turn R8 on fully, then
don’t hold it back Three settings get the most out of it, and one keep rule matters for AI. app/build.gradle.kts release { isMinifyEnabled = true isShrinkResources = true proguardFiles(getDefaultProguardFile( "proguard-android-optimize.txt"), "proguard-rules.pro") } proguard-rules.pro # Holds R8 back across the whole app -dontoptimize -keep class androidx.** { *; } # Keep only what needs it -keep class **.StarredSummaryOutput { *; } Turn it on Don’t hold it back The AI example Minify, shrink resources, the optimize rules file. Full mode is on by default. -dontoptimize and package-wide keeps stop R8 everywhere. If a @Generable class breaks in release, keep that one class. -
Android Dev Summit 2026 What else is new The rest
of this year’s tools and performance news. -
New at Android Dev Summit 2026 What the CLI learned
this year preview device remote device hub Compose previews with no phone. UI tasks 77% faster. A real phone from Google’s device lab. See and control any phone or emulator. profiler signals Agent plugins Traces and heap dumps. LeakCanary is on its way. Crashes and ANRs from real users. One install for Antigravity, Claude Code or Codex. From “What’s new in Android developer tools and performance”, Android Dev Summit 2026 -
New at Android Dev Summit 2026 More help with performance
R8 Compose 1.13 The analyzer is built into AGP 9.3. Jetpack Keep replaces broad rules. Tracing shows why a screen redrew. Heap dumps from users Image memory Policy and security A new vitals metric for image memory. Skills that check Play policy and security. Crashlytics captures real out-of-memory crashes. From “What’s new in Android developer tools and performance”, Android Dev Summit 2026 Performance Analyzer Android Studio’s profiler, now in the CLI. -
New at Android Dev Summit 2026 And when you do
open Android Studio Bring your own agent Change Review Views to Compose Over 40 agents run inside Android Studio. See what your agent changed, step by step. Moves XML layouts to Compose. XR emulators Android Bench Lightbuild Stable emulators for glasses. How AI models do on real Android tasks. An early, declarative build in YAML. From “What’s new in Android developer tools and performance”, Android Dev Summit 2026 -
Take it home Take the code home Every feature from
today is on GitHub, with the docs behind it. The droidconKE app Google’s AI on Android github.com/droidconKE/droidconKeKotlin developer.android.com/ai Also: github.com/android/skills · developer.android.com/develop/ui/compose/agentic -
Asante sana Questions? Harun Wangereka Android GDE · Senior Mobile
Engineer, SmileID