Your Cart
Loading

On-Device AI for Android: ML Kit, Local LLMs and Your Own Homelab AI Server in Kotlin Apps

On Sale
$19.00
$19.00
Added to cart

On-Device AI for Android is a practical guide to putting real AI features into a Kotlin app without sending everything to someone else's cloud. It starts with the decision that saves the most time: which of five options fits each feature (ML Kit, Gemini Nano, your own LiteRT model, a local language model with LiteRT-LM, or your own home server), all kept behind one small interface so a backend can change without touching your screens. Then it builds each one: ML Kit text recognition, PDFs, barcodes and translation; Gemini Nano through the ML Kit GenAI APIs with an honest look at device support and a status check before every call; LiteRT for your own models; a Gemma model running on the phone with LiteRT-LM, which replaces the MediaPipe LLM Inference API (now maintenance-only); model files delivered politely with Play for On-device AI or your own downloader; and a streaming chat against your own Ollama server over your home network or Tailscale. It closes with the responsibilities: Data safety, Google Play's AI-generated content rules, model licenses, battery and heat. Every library version and policy was checked against the official pages in October 2026, and the patterns come from real, public apps by the author, with the repository and file named. No benchmarks or speed claims.

What you get

  • A decision map: five on-device and self-hosted options compared, one interface with several backends, and a chooser that picks at runtime
  • ML Kit in an afternoon: bundled vs unbundled, text from photos and PDFs, the Google code scanner, translation and language ID
  • Gemini Nano without the guesswork: device support, the four feature states, summarization, the Prompt API, and what surprises people (AICore not ready yet, per-app quota)
  • Your own models: LiteRT's four steps of inference, MediaPipe Tasks, and a local LLM with LiteRT-LM streamed as a Kotlin Flow, with the ABI check that prevents a real crash
  • Shipping models politely: Play for On-device AI packs, a proper downloader, and only offering models a phone can actually hold
  • Your homelab AI server: Ollama reachable on purpose (LAN or Tailscale Serve with HTTPS), proving it with curl, reading the streamed reply line by line, cleartext rules, an OkHttp streaming backend, timeouts and a setup screen that diagnoses
  • A chat screen that streams in Compose, plus privacy, Play policy, battery and thermal headroom

60 pages, 23 diagrams plus a chapter-opener graphic for every chapter, a checklist and a cheat sheet. PDF and EPUB. Android the Right Way, Book 5.

Not sure yet? Read the free sample first: the cover, the full table of contents and all of Chapter 7, "Your Homelab AI Server" (making Ollama reachable on purpose, proving it with curl, the streamed reply line by line, Android's cleartext rules, an OkHttp streaming backend in Kotlin, timeouts and a setup screen that diagnoses), at https://payhip.com/b/Hz16R


Also in a bundle: Everything Bundle: all 11 ebooks, $89 ยท Android Bundle: 5 ebooks, $49. Code RIGHTWAY20 = 20% off any order through Oct 31.

You will get the following files:
  • PDF (3MB)
  • EPUB (3MB)