๐Ÿค– Android AI and Generative AI

What Is AI in Android Development? A Complete Developer's Guide

"Add AI to the app" can mean five very different things on Android, each with different costs, privacy implications and device requirements. This guide maps the whole landscape, shows a minimal example of each approach, and explains how to choose without the hype.

โœ๏ธ Yunok Tech ๐Ÿ“… Updated โฑ 9 min read ๐ŸŽฏ Beginner
On this page
  1. Two meanings of "AI in Android development"
  2. The landscape: five ways to add AI to an Android app
  3. Task-specific ML: still the right answer surprisingly often
  4. On-device generative AI: Gemini Nano
  5. Cloud generative AI: Gemini via Firebase AI Logic
  6. Where AI fits in your app architecture
  7. Real-world use cases and the right tool for each
  8. Production concerns teams underestimate
  9. A learning path through this series
  10. Frequently asked questions
  11. Conclusion

A product manager asks for "AI in the app". One developer imagines a chatbot. Another thinks of scanning receipts with the camera. A third plans to use AI to write the code faster. All three are "AI in Android development", but they share almost nothing in terms of architecture, cost, privacy or device support.

This guide is the starting point for the Yunoktech Android AI series. It's for Android developers who know Kotlin and want a clear, accurate map of the field: what kinds of AI exist on Android today, where each one runs, what it costs, which Google SDK provides it, and how it fits into a normal app architecture.

Two meanings of "AI in Android development"

  1. AI as a product feature: something your users experience, such as summarising a document, describing a photo, smart replies, semantic search or a support chat.
  2. AI as a development tool: assistants such as Gemini in Android Studio that help you write, explain, test and debug code. Your users never see these directly.

Most of this article is about the first meaning. The development-tools side is covered in How to Use Gemini in Android Studio.

The landscape: five ways to add AI to an Android app

Think of the options along two axes: what kind of model (a specialised task model or a general-purpose generative model) and where it runs (on the device or in the cloud).

Android AI landscape by model type and where it runs A two-by-two grid. On-device task-specific: ML Kit vision and language APIs, and custom LiteRT models. On-device generative: Gemini Nano through ML Kit GenAI APIs via AICore. Cloud generative: Gemini through Firebase AI Logic, or any provider through your own backend. Cloud task-specific: hosted vision and speech APIs called from a backend. RUNS ON DEVICERUNS IN THE CLOUD TASK-SPECIFIC ML GENERATIVE AI โ‘  ML Kit vision & languagetext recognition, barcodes, translation โ‘ก Custom models with LiteRTyour own trained model, bundled โ‘ข Gemini Nano (on-device LLM)ML Kit GenAI APIs โ†’ AICoresummarize, proofread, rewrite,describe images, prompt (beta) โ‘ฃ Cloud Gemini via Firebase AI LogicKotlin SDK, App Check protected โ‘ค Any model via your own backendGemini, OpenAI, open models, RAG Hosted task APIse.g. cloud vision / speech services,usually called from your backend
The Android AI landscape. Many production apps combine two or more of these approaches, for example on-device for privacy-sensitive quick tasks and cloud for heavy reasoning.
ApproachGood forNetworkCost modelMain limitation
โ‘  ML Kit vision/languageOCR, barcodes, face/pose detection, translation, language IDNot needed (bundled or downloaded models)No per-request feeFixed tasks only, no free-form generation
โ‘ก LiteRT custom modelYour own classifier, detector or recommenderNot neededYour training and engineering timeYou own the model lifecycle, size and accuracy
โ‘ข Gemini Nano (ML Kit GenAI)Summaries, proofreading, rewriting, image descriptions, short promptsNot needed after model downloadNo per-request feeOnly on supported devices; beta APIs; foreground only; per-app quota
โ‘ฃ Cloud Gemini (Firebase AI Logic)Chat, reasoning, long documents, multimodal inputRequiredPer token (free tier available)Latency, data leaves the device, cost at scale
โ‘ค Your own backendMulti-provider, RAG over private data, tools, strict controlRequiredPer token + server costsYou build and operate the backend

Task-specific ML: still the right answer surprisingly often

Before reaching for a large language model, ask whether the problem is really a fixed task. Reading text from a photo, scanning a barcode or detecting a language are solved problems with small, fast, free on-device models. An LLM would be slower, costlier and less predictable at them.

ReceiptScanner.ktKotlin
// Dependencies (use the latest versions from the ML Kit release notes):
//   implementation("com.google.mlkit:text-recognition:<version>")
//   implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:<version>")  // for await()
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.text.TextRecognition
import com.google.mlkit.vision.text.latin.TextRecognizerOptions
import kotlinx.coroutines.tasks.await

class ReceiptScanner {
    private val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)

    /** Returns all recognised lines, top to bottom. Runs fully on-device. */
    suspend fun readLines(bitmap: Bitmap, rotationDegrees: Int = 0): List<String> {
        val image = InputImage.fromBitmap(bitmap, rotationDegrees)
        val result = recognizer.process(image).await()
        return result.textBlocks.flatMap { block -> block.lines.map { it.text } }
    }

    fun close() = recognizer.close()
}

A common and effective pattern combines both kinds: run on-device OCR first, then send only the extracted text, not the photo, to a generative model to categorise the expense. That reduces cost, latency and the amount of personal data that leaves the device.

On-device generative AI: Gemini Nano

Gemini Nano is Google's on-device foundation model. It runs inside AICore, an Android system service that downloads, updates and hardware-accelerates the model, so your APK doesn't carry a multi-gigabyte model file. Apps access it through the ML Kit GenAI APIs: Summarization, Proofreading, Rewriting and Image Description, plus a more flexible Prompt API. At the time of writing these APIs are in beta (speech recognition is alpha), so check the current status before you depend on them.

The key constraints come straight from the official documentation:

  • Device support is limited to specific recent devices from several manufacturers. Always call checkFeatureStatus() before showing the feature.
  • Inference is allowed only while your app is the top foreground app. Background use, including from a foreground service, is blocked.
  • AICore enforces a per-app inference quota, so bursts of requests can return a BUSY error. Retry with exponential backoff.
  • Feature-specific limits apply. For example, summarisation input must be under about 4,000 tokens and supports a small set of languages.

The full walkthrough with code is in Gemini Nano and ML Kit GenAI on Android.

Cloud generative AI: Gemini via Firebase AI Logic

For open-ended chat, complex reasoning, long documents or broad multilingual support, you need a larger cloud model. Google's recommended path for calling Gemini directly from an Android app is the Firebase AI Logic SDK. It supports Kotlin coroutines and Flow, and it integrates with Firebase App Check to help ensure requests come from your genuine app rather than from someone who extracted your configuration.

Minimal Gemini call (Kotlin)Kotlin
// build.gradle.kts (app):
//   implementation(platform("com.google.firebase:firebase-bom:<latest>"))
//   implementation("com.google.firebase:firebase-ai")
import com.google.firebase.Firebase
import com.google.firebase.ai.ai
import com.google.firebase.ai.type.GenerativeBackend

// Model names change frequently: check the current list before release.
private const val MODEL_NAME = "gemini-3.8-flash"

val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(MODEL_NAME)

suspend fun suggestTitle(noteText: String): String? =
    model.generateContent("Suggest a short, specific title (max 6 words) for this note:\n$noteText").text
Never ship a raw API key

Don't embed a Gemini, OpenAI or any other provider's secret key in your APK. Anything in an APK can be extracted. Use Firebase AI Logic with App Check, or route requests through your own backend that holds the key and enforces per-user limits. Details are in Gemini API Integration in Android Using Kotlin.

Where AI fits in your app architecture

AI calls are just another data source, and slow, fallible and sometimes costly ones at that. Treat them like a network repository: hide the provider behind an interface, call it from a ViewModel inside a coroutine, and model loading, streaming, success and error as UI state.

AI feature inside a layered Android architecture Compose UI talks to a ViewModel, which calls an AiRepository interface. Implementations include an on-device Gemini Nano source and a cloud Gemini source, chosen at runtime based on availability. Compose UIrenders AiUiState ViewModelloading / stream / error AiRepositoryinterface + fallback On-deviceGemini Nano CloudGemini / backend
The UI never knows which model answered. That lets you add fallbacks, switch providers, or A/B test models without touching screens.
TextAssistant.ktKotlin
/** What the app needs from "AI", independent of the provider. */
interface TextAssistant {
    suspend fun isAvailable(): Boolean
    suspend fun summarize(text: String): String
}

/** Tries on-device first (private, free), falls back to cloud when unavailable. */
class FallbackTextAssistant(
    private val onDevice: TextAssistant,
    private val cloud: TextAssistant,
) : TextAssistant {
    override suspend fun isAvailable() = onDevice.isAvailable() || cloud.isAvailable()

    override suspend fun summarize(text: String): String =
        if (onDevice.isAvailable()) onDevice.summarize(text) else cloud.summarize(text)
}
Privacy changes with the path

If the fallback sends user text to the cloud, users must be told. Your privacy policy and the Play Console Data safety form need to reflect it. Some features should have no cloud fallback at all.

Real-world use cases and the right tool for each

Expense app: scan receipts

Problem
Typing receipt totals is tedious.
Solution
On-device ML Kit OCR โ†’ optional cloud model to categorise the extracted text.
Why
OCR is a fixed task; only small text leaves the device.
Trade-off
Categorisation needs a network connection and costs tokens.

Messaging app: polish a reply

Problem
Users want quick grammar fixes and tone changes.
Solution
ML Kit GenAI Proofreading/Rewriting on Gemini Nano.
Why
Private messages stay on the device; low latency; no per-call fee.
Trade-off
Only on supported devices, so hide the feature elsewhere or offer an opt-in cloud path.

Learning app: ask questions about course notes

Problem
Answers must come from the course material, not the open internet.
Solution
Backend RAG: retrieve relevant notes, send them with the question to a cloud model.
Why
Grounding in your own content reduces hallucinations.
Trade-off
Requires a backend, embeddings and evaluation work.

Production concerns teams underestimate

  • Non-determinism. The same prompt can produce different outputs. Design the UI for variation and let users edit or regenerate.
  • Hallucinations. Models can state false things confidently. Don't present generated text as verified fact, especially in health, finance or legal contexts.
  • Prompt injection. If the model reads untrusted content such as emails or web pages, that content can try to override your instructions. Never let model output trigger sensitive actions without validation or user confirmation.
  • Cost and quotas. Cloud costs scale with tokens. On-device has quotas. Add per-user limits, caching and graceful "try again later" states.
  • Evaluation. Keep a small set of real test inputs and review outputs whenever you change the prompt or the model version.
  • Accessibility and UX. Label AI-generated content, stream long responses so the UI feels responsive, and always provide a non-AI path.

A learning path through this series

  1. How to Choose the Right AI Model for an Android App: a decision framework.
  2. Cloud AI vs On-Device AI for Android: deployment trade-offs in depth.
  3. Gemini API Integration in Android Using Kotlin: your first cloud feature.
  4. Gemini Nano and ML Kit GenAI on Android: your first on-device feature.
  5. Build an AI Chatbot with Kotlin and Jetpack Compose: a complete project.

Frequently asked questions

Do I need to know machine learning to add AI to an Android app?

No. ML Kit and Firebase AI Logic expose high-level Kotlin APIs. You need solid Android skills (coroutines, state management, error handling) plus an understanding of model limitations, privacy and cost. Training your own models with LiteRT is where ML knowledge becomes necessary.

Does Gemini Nano work on every Android phone?

No. It requires AICore and supported hardware, and the device list is published on the ML Kit GenAI page. Your app must check feature status at runtime and offer a fallback or hide the feature.

Is it safe to call an AI API directly from the app?

Only through a mechanism designed for it, such as Firebase AI Logic with App Check. Never embed a raw provider API key in the APK. For multi-provider setups or sensitive logic, use your own backend.

Can I use OpenAI or other models in an Android app?

Yes, typically through your own backend that holds the API key and calls the provider. The Android app talks to your backend, which also lets you switch providers later.

What's the difference between ML Kit and ML Kit GenAI?

Classic ML Kit provides task-specific models such as text recognition and barcode scanning. ML Kit GenAI provides generative features such as summarisation and rewriting, powered by Gemini Nano through AICore on supported devices.

Conclusion

AI in Android development isn't one technology. It's a toolbox: task-specific on-device ML for fixed problems, Gemini Nano for private on-device generation on supported devices, and cloud models through Firebase AI Logic or your own backend for heavier reasoning. Whichever you choose, it slots into the same architecture you already know: a repository behind an interface, called from a ViewModel, with honest loading and error states.

Next step: write down one AI feature idea for your app and decide which of the five approaches fits it. Then use the framework in How to Choose the Right AI Model for an Android App to check your choice.

Official references

๐Ÿ“ฑ Apps built by Yunok Tech

Real Android apps on Google Play, free to download.

See all our apps โ†’

Ready to build real Android applications?

Every AI feature still runs inside an Android app that has to be fast, reliable and well structured. Strengthen the Kotlin, Jetpack Compose and architecture skills that AI integrations depend on, then apply these AI concepts with confidence.

Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.

Explore the Android course and take your next step as an Android developer.

Share: LinkedIn X / Twitter WhatsApp