IntermediateEnglish14 lectures · 1h 42m

Ship an LLM in an Android App

Kotlin with Compose and MediaPipe, React Native with llama.rn, hardware acceleration and NPU verification

Watch 3 lectures free

What you'll learn

  • Integrate an on-device LLM in a Kotlin/Compose app with MediaPipe and a foreground service
  • Integrate the same model in React Native with llama.rn, including model download and streaming
  • Build an on-device RAG pipeline with embeddings and a SQLite vector store
  • Use execution-provider fallback, profile with Android Studio Profiler and Perfetto, and verify NPU offload
  • Spot and fix the threading, lifecycle and memory mistakes that make on-device AI apps fail

About this course

A model that runs in a notebook is not an app. This course puts a quantized language model inside a real Android application — twice, in two stacks — and is explicit about everything that breaks on a real phone.

Track A is Kotlin: project and Gradle setup, a MediaPipe LLM engine wrapper, a ViewModel, a Jetpack Compose chat screen, a foreground service that keeps generating in the background, model files in assets, and an on-device RAG pipeline with embeddings and a SQLite vector store. Track B is React Native with llama.rn: project setup, Metro configuration for large model files, an LLM service module, a model downloader with progress, and a streaming chat hook and screen. Then hardware acceleration: the execution-provider fallback chain, calling Qualcomm QNN through JNI, profiling with Android Studio Profiler and Perfetto, and verifying from logcat that the NPU is really doing the work. An appendix covers migrating to Gemma 4 and LiteRT-LM with native tool calling.

The code is walked through by intent — threading, lifecycle, memory, cancellation — and the narration says out loud which parts of the sample code must be fixed before you ship, which makes them the real exercises of the course.

**Licensing.** Getting weights onto a user's phone is redistribution, so this course ships a `Resources/LICENSES.md` with every asset checked against its actual licence text. **Gemma 2, used in Track A and Track B, is commercially usable but obliges you to give every user a copy of the Gemma Terms of Use, reproduce its notice string verbatim, and carry its Prohibited Use Policy into your own terms** — all of which are things you build into the app, not paperwork you do afterwards. The Section 4 appendix moves to Gemma 4, which Google released under Apache-2.0 and which drops those obligations entirely.

Curriculum5 sections · 14 lectures · 1h 42m

Section 0. Welcome

Free preview

Section 1. Track A Native Android LLM App

Free preview

Section 2. Track B React Native LLM App

  • 🔒why llama rn setup metro service download9:00
  • 🔒usechat hook screen running and issues8:18

Section 3. Hardware Acceleration and NPU Verification

  • 🔒section 3 intro0:12
  • 🔒part5 kickoff backend matrix ep fallback qnn jni9:12
  • 🔒android studio profiler perfetto benchmark gauge7:48
  • 🔒npu offload verification ep status tuning targets9:36

Section 4. Appendix Gemma 4 and LiteRT-LM

  • 🔒appendix gemma4 e2b litert lm and downloader8:48
  • 🔒appendix dual gemma engine and chat templates8:12
  • 🔒appendix tool calling agent migration checklist adoption11:18

Requirements

  • · A computer with Python 3.10+ (a free Google Colab account is enough for most sessions)
  • · Comfort reading Python code; you do not need to be an expert
  • · A quantized model in GGUF or ONNX form (our Model Preparation course, or your own)
  • · Android Studio (Track A) and/or a React Native toolchain (Track B)
  • · Kotlin or TypeScript basics; you can follow one track only
  • · Willingness to read `Resources/LICENSES.md`: shipping Gemma 2 obliges you to pass its Terms and Prohibited Use Policy on to your users

Who this is for

  • · Android and React Native developers adding on-device AI features
  • · ML engineers who need to ship a model inside an app, not a server
  • · Teams choosing between a native and a cross-platform stack

Read alongside the course

    The voice-over in this course is synthesized with a text-to-speech model from scripts written and reviewed by the instructor, and the on-screen material (notebooks, code, slides) is the instructor's own work.

    Ship an LLM in an Android App | SOTAAZ Blog