Next live event: Vibe Coding Android Apps: Do You Still Need to Learn Kotlin?, 2 Dec 2026, 8:00 PM IST. Reserve a seat

Free series · 5 episodes live · 64 min so far

On-Device RAG for Android, with Gemma.

Put your phone in airplane mode. Ask it about a private PDF. Gemma answers from the file, and nothing leaves the device. This free Kotlin series builds that app, one episode at a time.

For Android developers who already ship Kotlin apps. No machine learning background needed.

  • Kotlin
  • Gemma 4
  • LiteRT LM
  • EmbeddingGemma
  • Free on YouTube
Course trailer: on-device RAG for Android with Gemma
The trailer shows the app and the plan. Episode 1 starts below.
  • Taught by Belal Khan
  • Google Developer Expert for Android
  • 10+ years building mobile software
  • 118K+ developers on YouTube

Advertisement

Watch the episodes

How do you build on-device RAG on Android with Gemma? Search before generation.

Gemma has never read your file. Every answer is only as good as the search that finds the right passage for it. Watch in order: each episode adds one part of the app.

5 free episodes live, more coming
  1. Episode 1 thumbnail: Can Android Run AI Without the Internet? Gemma + RAGSTART HEREPlay here11:25
    EP 0111:25 min

    Can Android Run AI Without the Internet? Gemma + RAG

    The phone is in airplane mode. The document never leaves it. Gemma still answers.

    Gemma has never seen your file, so how can it answer questions about it? Meet RAG and the one idea behind the whole series: search before generation.

  2. Episode 2 thumbnail: Can You Run Gemma 4 Directly on Android?Play here16:05
    EP 0216:05 min

    Can You Run Gemma 4 Directly on Android?

    Gemma 4 runs on the phone, and the reply streams in as it writes.

    Start Gemma 4 on Android with LiteRT LM, stream replies on the device and keep the conversation going. You also see why this series uses LiteRT LM, and where llama.cpp can still win.

  3. Episode 3 thumbnail: Build Semantic Search on Android with EmbeddingGemmaPlay here14:44
    EP 0314:44 min

    Build Semantic Search on Android with EmbeddingGemma

    The closest vector is not always the right answer.

    Watch embeddings, cosine similarity and Top K rank results on a phone. Then ask the question demos skip: what happens when the answer is not in your data? Vector search still returns something.

  4. Episode 4 thumbnail: How to Chunk PDFs for RAG on Android Without Losing ContextPlay here10:55
    EP 0410:55 min

    How to Chunk PDFs for RAG on Android Without Losing Context

    Splitting text is easy. Splitting it well is the hard part.

    Turn a real PDF into searchable chunks inside an Android app: extract, clean and split with overlap. Then fix what breaks at the boundary between two chunks.

  5. Episode 5 thumbnail: Build Hybrid Search for Android RAG: BM25 + Semantic SearchPlay here10:44
    EP 0510:44 min

    Build Hybrid Search for Android RAG: BM25 + Semantic Search

    Semantic search ranked the exact answer fifth. Hybrid search moved it to first.

    Search a saved PDF for uric acid and watch semantic search miss the measured result. Add BM25 for exact words, merge both rankings with Reciprocal Rank Fusion in Kotlin and test both failure modes.

Prefer YouTube? Open the full playlist ↗

Source code on GitHubThe repository is updated episode by episode, in the same order as the series.
View the repository

The idea in one minute

What is on-device RAG, and why run it on a phone?

On-Device RAG lets a phone answer questions from your own documents without calling a cloud model. The app searches the documents first. Then a local model such as Gemma writes the answer from what the search found.

Your documents stay on the device, and the whole path works offline once the model files are installed. The catch: a small model is only as good as the evidence you hand it. That is why most of this series is about search, not prompts.

What each episode adds to the app

  1. See the whole pipelineWhy the app searches first, and how the pieces fit.
    EP 1
  2. Run Gemma 4 on the phoneLiteRT LM starts the model and streams the reply.
    EP 2
  3. Search by meaningEmbeddingGemma, cosine similarity, Top K and a rule for when nothing matches.
    EP 3
  4. Chunk a real PDFExtract, clean and split with overlap so no fact falls between two pieces.
    EP 4
  5. Add keyword searchBM25 catches exact words, and Reciprocal Rank Fusion merges it with semantic search.
    EP 5
  6. Answer with evidence and citationsHand the best chunks to Gemma and show where each answer came from.
    Coming next

What the series covers

Eight topics, from a first answer to a shippable feature.

4 of 8 topics have live episodes.
  1. 01

    The offline RAG pipeline

    How private documents become chunks, evidence, an answer and a citation, end to end.

  2. 02

    Run Gemma on the phone

    Start the model with LiteRT LM, stream tokens, keep the conversation going and know which state the runtime owns.

  3. 03

    Embeddings, chunking and local search

    How text becomes vectors, how chunk boundaries change retrieval and how to search the vectors on the device.

  4. 04

    Better retrieval

    Why a close vector can still be the wrong evidence, and how keywords, metadata, thresholds and reranking fix it.

  5. 05

    Prompts and context for a small model

    Choose, label, order and trim evidence for a model with a small context window.

    Coming next
  6. 06

    Hallucinations, citations and evaluation

    Tell a retrieval failure from a generation failure, then measure groundedness, refusals, latency and regressions.

    Coming next
  7. 07

    Speed, memory, battery and heat

    Measure startup, time to first token, memory pressure and thermal limits on real phones.

    Coming next
  8. 08

    Shipping the model

    Downloads, integrity checks, versioning, licences and an optional cloud fallback the user agrees to.

    Coming next

Before you start

Is this series right for you?

Good fit

You will get a lot from it if you

  • Build Android apps in Kotlin and know coroutines and local storage.
  • Want AI features that keep user data on the phone.
  • Care why retrieval fails, not only how to call an API.

Not the right fit

Look elsewhere if you

  • Are new to Android. The basics are not taught here.
  • Want to type along with every Compose screen. Routine boilerplate is skipped.
  • Need a packaged SDK. This is a case study, not a library.
Belal Khan teaching on stage

Your instructor

Taught by Belal Khan.

I am an Android engineer and a Google Developer Expert for Android. I have built mobile apps for more than ten years, including apps used by tens of millions of people.

Lately I build on-device AI: RAG with small models such as Gemma and Gemini Nano, and agents on mobile with MCP. I have spoken at 100+ in-person events, including Droidcon India 2026, where I talked about what actually works for RAG on Android.

This series comes from building the app myself. I show the choices that worked, the failures that changed the design and what I would fix before calling it production-ready.

10+years in mobile
100+events spoken at
118K+on YouTube
GDEAndroid
More about Belal →This series is my own work and reflects my own views.

Frequently asked

Questions before you press play.

Is the series free?

Yes. Every episode is free on the Simplified Coding YouTube channel. You do not need an account to watch.

What is on-device RAG?

On-Device RAG is a way to answer questions from your own documents with a model that runs on the phone. The app searches the documents first, then the model writes the answer from what the search found.

Do I need machine learning experience?

No. You need Android and Kotlin experience. The AI ideas are explained from an Android engineer's point of view, and Compose screens, navigation and dependency injection are not taught.

Will we build a complete app?

The series follows a complete working app and focuses on the RAG and AI parts. The code is on GitHub and is updated episode by episode.

Does it work without the internet?

Yes, once the model files are on the device and your documents are indexed. Speed and quality depend on the phone.

How do you run Gemma on Android?

This series uses LiteRT LM. Episode 2 starts Gemma 4 on the phone, streams the reply and keeps the conversation going. It also explains where llama.cpp can still be the better pick.

What is EmbeddingGemma used for?

It turns text into vectors, so the app can search by meaning instead of exact words. Episode 3 uses it for semantic search on the phone, with cosine similarity and Top K.

How do you chunk a PDF for RAG?

Extract and clean the text, then split it into pieces with some overlap, so no fact falls between two chunks. Episode 4 does this on a real PDF and fixes what breaks at the boundaries.

What is hybrid search in RAG?

Hybrid search mixes two rankings: semantic search, which matches meaning, and BM25, which matches exact words. Episode 5 merges them with Reciprocal Rank Fusion in Kotlin, so a test name or error code is not lost.

How many episodes are there, and when is the next one?

5 are live. Each new episode is added to this page when it is published. No fixed schedule is promised.

Your first step

Start with episode 1. It takes 11 minutes.

It sets up the one idea every later episode builds on: search before generation. Subscribe and the next episode finds you.

Start with episode 1