On-Device AI on Android: Gemini Nano and ML Kit GenAI APIs
← BACK TO WRITING
November 18, 2026

By , Android developer & software engineer

On-Device AI on Android: Gemini Nano and ML Kit GenAI APIs

Run AI directly on the phone with Gemini Nano and ML Kit GenAI APIs: privacy, offline use, device support, a Compose summarizer, cloud fallback and limits.

What if your app could summarize an article, fix grammar, or describe a photo, even in airplane mode? That is the promise of on-device AI Android developers can now use through Gemini Nano and the ML Kit GenAI APIs. In this guide, I will explain how it works, which phones support it, and how to build a working summarizer screen with Kotlin and Jetpack Compose.

I will also show you what to do when a device does not support it, because many phones still don't. Let's start with the big question.

On-Device AI vs Cloud AI: What Is the Difference?

Imagine two kinds of cooks. One is a world-famous chef in a big restaurant across the city. The other is a skilled home cook already in your kitchen. The famous chef can cook anything, but you must send the order, wait for delivery, and pay every time. The home cook has fewer recipes, but is instant, free, and never leaves your house.

Cloud AI is the famous chef. On-device AI is the home cook.

FactorOn-Device AI (Gemini Nano)Cloud AI (Gemini Flash/Pro)
PrivacyData never leaves the phoneData is sent to a server
OfflineWorks without internetNeeds internet
LatencyNo network delayNetwork delay on every call
CostNo per-request costPay per token after free tier
CapabilitySmaller model, shorter inputMuch stronger reasoning, long context
Device supportOnly supported devicesAlmost any device with internet

So the choice is not "which is better". It is "which fits this feature". A note-taking app that summarizes private notes? On-device is perfect. A coding assistant that reasons over large documents? Use the cloud.

If you want to understand why a smaller model has a smaller "memory", my upcoming post on how LLMs work: tokens, context and temperature explains it simply.

What Is Gemini Nano?

Gemini Nano is Google's smallest Gemini model, built to run directly on mobile hardware. You do not ship it inside your APK. Instead, it lives in AICore, an Android system service.

Think of AICore like Google Play services, but for AI models. It:

  • Downloads and updates the Gemini Nano model for all apps.
  • Uses the phone's hardware accelerators for fast inference.
  • Runs safety filters on inputs and outputs.
  • Does not store your prompts or results after processing.
  • Has no direct internet access. Model downloads go through Private Compute Services.

This design is great for you as a developer. Your APK stays small, and many apps can share one model instead of each app downloading gigabytes.

Which Devices Support Gemini Nano?

This is the most important limitation. As of November 2026, Gemini Nano is not available on every Android phone. It needs recent, powerful hardware.

According to the official ML Kit GenAI device list, support includes:

  • Recent Google Pixel phones, such as the Pixel 10 and Pixel 11 series.
  • Selected flagship and upper-mid-range phones from other manufacturers (for example, some POCO models).
  • Some newer devices like Googlebook laptops.

Google also says model availability and version can vary based on the device's RAM, OS version, and AICore update status. There are now different generations (Gemini Nano 2, 3, and 4) on different devices.

Warning: The ML Kit GenAI APIs do not work on devices with an unlocked bootloader. Also, never decide support by checking the phone model name. Always ask the API at runtime, as I show below.

In Bangladesh and many other markets, most users still have budget and mid-range phones. So treat on-device generative AI as a bonus feature, not the only path.

The ML Kit GenAI APIs Explained

You can use Gemini Nano through ML Kit's GenAI APIs. They are grouped into a few families (as of November 2026):

Text and image tasks (high-level, easiest):

APIWhat it doesArtifact
SummarizationSummarizes articles or chats into 1-3 bulletscom.google.mlkit:genai-summarization
ProofreadingFixes grammar and spelling in short messagescom.google.mlkit:genai-proofreading
RewritingChanges tone or style of short messagescom.google.mlkit:genai-rewriting
Image DescriptionGenerates a short description of an imagecom.google.mlkit:genai-image-description

These four are in beta at version 1.0.0-beta1, which means no SLA and possible API changes.

Custom generation (more flexible):

  • Prompt API / direct model access (com.google.mlkit:genai-prompt, 1.0.0-beta5): send your own text or image prompts to Gemini Nano with the GenerativeModel class, including multi-turn chats.
  • Agentic workflows (genai-agent, alpha): manages sessions and tool calling on top of the Prompt API.

Newer alpha APIs: speech recognition, speech translation, text to speech, and embeddings for semantic search. These are early, so expect changes.

My advice: start with the high-level task APIs. They are tuned for one job and are much easier to get right than writing your own prompts.

Step 1: Add the Summarization Dependency

Your app needs minSdk 26 or higher. In your app-level build.gradle.kts:

dependencies {
    implementation("com.google.mlkit:genai-summarization:1.0.0-beta1")

    // Lets us call .await() on ListenableFuture inside coroutines
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.11.0")

    implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.11.0")
    implementation("androidx.lifecycle:lifecycle-runtime-compose:2.11.0")
}

Tip: Version numbers are from the ML Kit release notes as of November 2026. Check them again before you publish your app.

Step 2: Check Availability and Download the Model

Every ML Kit GenAI feature follows the same pattern:

  1. Create a client with options.
  2. Call checkFeatureStatus().
  3. If needed, download the feature.
  4. Run inference.
  5. Close the client when done.

The status can be one of four values:

  • UNAVAILABLE: this device cannot run the feature. Hide the button or use the cloud.
  • DOWNLOADABLE: supported, but the model must be downloaded first.
  • DOWNLOADING: a download is already in progress.
  • AVAILABLE: ready to use right now.

Step 3: Build the SummaryViewModel

Here is a ViewModel that handles all states. I keep the state in a sealed interface, like in my Jetpack Compose state management guide.

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
import com.google.mlkit.genai.common.DownloadCallback
import com.google.mlkit.genai.common.FeatureStatus
import com.google.mlkit.genai.common.GenAiException
import com.google.mlkit.genai.summarization.Summarization
import com.google.mlkit.genai.summarization.SummarizationRequest
import com.google.mlkit.genai.summarization.Summarizer
import com.google.mlkit.genai.summarization.SummarizerOptions
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.guava.await
import kotlinx.coroutines.launch

sealed interface SummaryUiState {
    data object Idle : SummaryUiState
    data object Checking : SummaryUiState
    data class Downloading(val downloadedBytes: Long, val totalBytes: Long) : SummaryUiState
    data class Summarizing(val partial: String) : SummaryUiState
    data class Success(val summary: String) : SummaryUiState
    data object NotSupported : SummaryUiState
    data class Error(val message: String) : SummaryUiState
}

class SummaryViewModel(application: Application) : AndroidViewModel(application) {

    private val summarizer: Summarizer = Summarization.getClient(
        SummarizerOptions.builder(application)
            .setInputType(SummarizerOptions.InputType.ARTICLE)
            .setOutputType(SummarizerOptions.OutputType.THREE_BULLETS)
            .setLanguage(SummarizerOptions.Language.ENGLISH)
            .build()
    )

    private val _uiState = MutableStateFlow<SummaryUiState>(SummaryUiState.Idle)
    val uiState: StateFlow<SummaryUiState> = _uiState.asStateFlow()

    private var totalBytes = 0L

    fun summarize(text: String) {
        if (text.length < 400) {
            _uiState.value = SummaryUiState.Error("Please enter a longer article (400+ characters).")
            return
        }
        viewModelScope.launch {
            try {
                _uiState.value = SummaryUiState.Checking
                when (summarizer.checkFeatureStatus().await()) {
                    FeatureStatus.UNAVAILABLE -> _uiState.value = SummaryUiState.NotSupported
                    FeatureStatus.DOWNLOADABLE -> downloadThenRun(text)
                    // If a download is running, inference waits for it to finish
                    FeatureStatus.DOWNLOADING,
                    FeatureStatus.AVAILABLE -> runSummary(text)
                }
            } catch (e: CancellationException) {
                throw e
            } catch (e: Exception) {
                _uiState.value = SummaryUiState.Error(e.message ?: "Summarization failed.")
            }
        }
    }

    private fun downloadThenRun(text: String) {
        summarizer.downloadFeature(object : DownloadCallback {
            override fun onDownloadStarted(bytesToDownload: Long) {
                totalBytes = bytesToDownload
                _uiState.value = SummaryUiState.Downloading(0, bytesToDownload)
            }

            override fun onDownloadProgress(totalBytesDownloaded: Long) {
                _uiState.value = SummaryUiState.Downloading(totalBytesDownloaded, totalBytes)
            }

            override fun onDownloadCompleted() {
                viewModelScope.launch {
                    try {
                        runSummary(text)
                    } catch (e: CancellationException) {
                        throw e
                    } catch (e: Exception) {
                        _uiState.value = SummaryUiState.Error(e.message ?: "Summarization failed.")
                    }
                }
            }

            override fun onDownloadFailed(e: GenAiException) {
                _uiState.value = SummaryUiState.Error("Model download failed: ${e.message}")
            }
        })
    }

    private suspend fun runSummary(text: String) {
        val request = SummarizationRequest.builder(text).build()
        var partial = ""
        _uiState.value = SummaryUiState.Summarizing("")

        // Streaming: the callback receives new text as it is generated
        val result = summarizer.runInference(request) { newText ->
            partial += newText
            _uiState.value = SummaryUiState.Summarizing(partial)
        }.await()

        _uiState.value = SummaryUiState.Success(result.summary)
    }

    override fun onCleared() {
        summarizer.close() // free AICore resources
        super.onCleared()
    }
}

Let's understand it:

  • SummarizerOptions describes the job: an ARTICLE input, THREE_BULLETS output, in English. You can also use CONVERSATION input for chat logs.
  • checkFeatureStatus() returns a ListenableFuture. The await() extension from kotlinx-coroutines-guava turns it into a simple suspend call.
  • downloadFeature() reports progress through DownloadCallback, so we can show a real progress bar.
  • runInference(request) { newText -> } streams the summary piece by piece. The returned future gives the final summary.
  • summarizer.close() in onCleared() releases the model resources. Do not forget this.
  • MutableStateFlow is thread-safe, so updating it from ML Kit callbacks is fine.

Tip: The summarizer accepts up to about 4,000 tokens (roughly 3,000 English words). For longer text, call setLongInputAutoTruncationEnabled(true) on the options builder, split the text into chunks, or send it to the cloud.

Step 4: Wire It Into a Compose Screen

Now the UI. If ViewModels in Compose are new to you, start with Jetpack Compose ViewModel for beginners.

@Composable
fun SummaryScreen(viewModel: SummaryViewModel = viewModel()) {
    val state by viewModel.uiState.collectAsStateWithLifecycle()
    var article by rememberSaveable { mutableStateOf("") }

    Column(
        modifier = Modifier
            .fillMaxSize()
            .padding(16.dp)
            .verticalScroll(rememberScrollState()),
        verticalArrangement = Arrangement.spacedBy(12.dp)
    ) {
        OutlinedTextField(
            value = article,
            onValueChange = { article = it },
            label = { Text("Paste an article") },
            modifier = Modifier.fillMaxWidth().heightIn(min = 160.dp)
        )

        val busy = state is SummaryUiState.Checking ||
            state is SummaryUiState.Downloading ||
            state is SummaryUiState.Summarizing

        Button(
            onClick = { viewModel.summarize(article) },
            enabled = !busy && article.isNotBlank()
        ) {
            Text("Summarize on device")
        }

        when (val s = state) {
            SummaryUiState.Idle -> Unit
            SummaryUiState.Checking -> Text("Checking device support...")
            is SummaryUiState.Downloading -> {
                val progress = if (s.totalBytes > 0) s.downloadedBytes.toFloat() / s.totalBytes else 0f
                Text("Downloading AI model (one time only)...")
                LinearProgressIndicator(progress = { progress }, modifier = Modifier.fillMaxWidth())
            }
            is SummaryUiState.Summarizing -> Text(s.partial.ifEmpty { "Summarizing..." })
            is SummaryUiState.Success -> Text(s.summary, style = MaterialTheme.typography.bodyLarge)
            SummaryUiState.NotSupported -> Text(
                "On-device AI is not available on this phone. Try the online summary instead."
            )
            is SummaryUiState.Error -> Text(s.message, color = MaterialTheme.colorScheme.error)
        }
    }
}

Let's understand it:

  • The when block maps every state to a clear UI. No state is forgotten, because the sealed interface forces us to handle all cases.
  • The button is disabled while work is running, so users cannot start two jobs.
  • A one-time download message tells users why the first run is slower.
  • NotSupported gives a friendly path forward instead of a dead end.

For more ideas on these screens, see loading and error states in Jetpack Compose.

Fallback to the Cloud When Gemini Nano Is Unavailable

Remember, many users will see UNAVAILABLE. A good app does not just say "sorry". It falls back to a cloud model.

A clean way is to hide both behind one interface:

interface TextSummarizer {
    suspend fun summarize(text: String): String
}

class OnDeviceSummarizer(/* ML Kit Summarizer */) : TextSummarizer { /* ... */ }
class CloudSummarizer(/* Firebase AI Logic model */) : TextSummarizer { /* ... */ }

Your repository checks checkFeatureStatus() and picks the right implementation. This fits nicely with clean architecture on Android.

For the cloud side, follow my guide Add an AI Chat to Your Android App with the Gemini API. It uses Firebase AI Logic with App Check, so you never put an API key in your app.

Tip: Firebase AI Logic also offers a hybrid inference API. It can use the on-device model when available and automatically fall back to a cloud Gemini model. Check the Android hybrid AI guide to see if it fits your use case.

Be honest with users about the switch. If you promise "your notes never leave your phone", do not silently send them to the cloud. Ask first, or show a clear label.

Limitations You Should Know

On-device generative AI is exciting, but it is not magic. Here are the real limits as of November 2026:

  • Device coverage is limited. Only supported devices, and never with an unlocked bootloader.
  • Beta and alpha status. The APIs can change between versions, and there is no SLA.
  • Short inputs. Summarization is limited to about 4,000 tokens, and article input should be over 400 characters.
  • Few languages. Summarization supports English, Japanese, and Korean. Bengali users, for example, are not covered yet.
  • Weaker reasoning. Nano is good at focused tasks, not complex multi-step thinking.
  • First-run download. The model may need to download first, which takes time and storage.
  • Hardware-dependent speed. Older supported devices are slower.

Also remember that AI can be wrong. Summaries may miss details. Show results as suggestions, not facts. For more on keeping AI features safe, read AI security testing on Android.

Classic ML Kit: On-Device AI That Works on Most Phones

Here is something many developers forget. Before generative AI, ML Kit already had excellent non-generative on-device APIs. They are small, fast, free, and work on a huge range of Android devices, not just flagships.

APIUse caseArtifact (as of Nov 2026)
Text RecognitionRead text from photos (receipts, cards)com.google.mlkit:text-recognition:16.0.1
Barcode ScanningQR codes, product barcodescom.google.mlkit:barcode-scanning:17.3.0
TranslationOffline translation between many languagescom.google.mlkit:translate:17.0.3

If your feature is "read the text on this receipt" or "scan this QR code", you do not need a large language model at all. Classic ML Kit is the faster, cheaper, more reliable choice. I am writing a full guide on ML Kit text recognition with Jetpack Compose, coming soon.

A smart pattern is to combine them: use text recognition to read a document, then summarize the text with Gemini Nano if available, or with the cloud if not.

Frequently Asked Questions

Does Gemini Nano work on all Android phones? No. As of November 2026, it runs only on supported devices through AICore, such as recent Pixel phones and selected devices from other manufacturers. Always call checkFeatureStatus() at runtime.

Is on-device AI on Android free to use? Yes. The ML Kit GenAI APIs run locally, so there is no per-request cost. The ML Kit GenAI Additional Terms of Service still apply.

Do I need to bundle the Gemini Nano model in my APK? No. AICore manages the model. Your app only calls downloadFeature() or lets the first inference trigger the download.

What is the difference between ML Kit GenAI APIs and the Prompt API? The task APIs (summarization, proofreading, rewriting, image description) are tuned for one job and are easy to use. The Prompt API gives direct access to Gemini Nano with your own prompts, which is more flexible but needs more testing. My upcoming prompt engineering for developers guide will help.

Key Takeaways

  • On-device AI Android features give you privacy, offline support, low latency, and zero per-request cost, but less power than cloud models.
  • Gemini Nano runs inside AICore and is available only on supported devices as of November 2026.
  • ML Kit GenAI offers summarization, proofreading, rewriting, and image description (beta), plus the Prompt API and newer alpha APIs.
  • Always follow the pattern: create client, checkFeatureStatus(), download if needed, run inference, close().
  • Plan a cloud fallback with Firebase AI Logic for unsupported devices.
  • For OCR, barcodes, and translation, classic ML Kit APIs work on most phones and are often the better choice.
© 2026 SHAKIL AHMED. SYSTEM: ANTIGRAVITY OS v1.0